Skip to content

Commit 2da03ff

Browse files
authored
Compiling content-only projects
Adds support for compiling .docsproj files that have MintlifyTemplates but no assemblies.
2 parents 56615fe + d527e37 commit 2da03ff

9 files changed

Lines changed: 80 additions & 23 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,5 @@ FodyWeavers.xsd
421421
/merge-solution.txt
422422
/opencode-prompt.txt
423423
/test-home
424+
/reset-counter.ps1
425+
/update-counter.ps1

src/CloudNimble.DotNetDocs.Core/DocumentationManager.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,20 @@ public async Task ProcessAsync(IEnumerable<(string assemblyPath, string xmlPath)
115115
var assemblyList = assemblies.ToList();
116116
var hasReferences = projectContext.DocumentationReferences.Any();
117117

118-
// Documentation-only mode: only process references, no assemblies
118+
// Documentation-only mode: process references and/or template without local assemblies
119119
if (assemblyList.Count == 0)
120120
{
121-
if (hasReferences)
121+
// Run pipeline if we have references OR a MintlifyTemplate
122+
if (hasReferences || projectContext.HasMintlifyTemplate)
122123
{
123-
// Process referenced documentation with format-specific handlers
124-
await ProcessDocumentationReferencesAsync();
124+
if (hasReferences)
125+
{
126+
// Process referenced documentation with format-specific handlers
127+
await ProcessDocumentationReferencesAsync();
128+
}
125129

126-
// Renderers still need to run for navigation file processing (pass null model)
130+
// Renderers run for navigation file processing (pass null model)
131+
// For Mintlify: generates docs.json from template + discovers content files
127132
foreach (var renderer in renderers)
128133
{
129134
await renderer.RenderAsync(null);

src/CloudNimble.DotNetDocs.Core/ProjectContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ public class ProjectContext
155155
/// </value>
156156
public bool ConceptualDocsEnabled { get; set; } = true;
157157

158+
/// <summary>
159+
/// Gets or sets whether a MintlifyTemplate is defined.
160+
/// </summary>
161+
/// <value>
162+
/// When true, docs.json will be generated even without assemblies to document.
163+
/// The presence of a template is an explicit signal that the user wants documentation output.
164+
/// </value>
165+
public bool HasMintlifyTemplate { get; set; } = false;
166+
158167
/// <summary>
159168
/// Gets or sets the collection of external documentation references to combine into this documentation collection.
160169
/// </summary>

src/CloudNimble.DotNetDocs.Docs/CloudNimble.DotNetDocs.Docs.docsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<NamespaceMode>Folder</NamespaceMode>
77
<ShowDocumentationStats>true</ShowDocumentationStats>
88
<!-- Exclude test projects from documentation -->
9-
<ExcludePatterns>Tests.Shared;*.Sdk</ExcludePatterns>
9+
<ExcludePatterns>Tests.Shared;*.Sdk;test</ExcludePatterns>
1010

1111
<ConceptualDocsEnabled>true</ConceptualDocsEnabled>
1212
<ShowPlaceholders>false</ShowPlaceholders>

src/CloudNimble.DotNetDocs.Docs/api-reference/CloudNimble/DotNetDocs/Core/ProjectContext.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,22 @@ public CloudNimble.DotNetDocs.Core.Configuration.FileNamingOptions FileNamingOpt
252252
Type: `CloudNimble.DotNetDocs.Core.Configuration.FileNamingOptions`
253253
Configuration for how documentation files are named and organized.
254254

255+
### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> HasMintlifyTemplate
256+
257+
Gets or sets whether a MintlifyTemplate is defined.
258+
259+
#### Syntax
260+
261+
```csharp
262+
public bool HasMintlifyTemplate { get; set; }
263+
```
264+
265+
#### Property Value
266+
267+
Type: `bool`
268+
When true, docs.json will be generated even without assemblies to document.
269+
The presence of a template is an explicit signal that the user wants documentation output.
270+
255271
### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> IncludedMembers
256272

257273
Gets or sets the list of member accessibilities to include in documentation.

src/CloudNimble.DotNetDocs.Sdk.Tasks/GenerateDocumentationTask.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ public class GenerateDocumentationTask : Task
115115
/// </summary>
116116
public ITaskItem[]? ResolvedDocumentationReferences { get; set; }
117117

118+
/// <summary>
119+
/// Gets or sets whether a MintlifyTemplate is defined (inline or file-based).
120+
/// </summary>
121+
/// <value>
122+
/// When true, always generate docs.json regardless of assemblies.
123+
/// The presence of a template is an explicit signal that the user wants documentation output.
124+
/// </value>
125+
public bool HasMintlifyTemplate { get; set; } = false;
126+
118127
#endregion
119128

120129
#region Public Methods
@@ -186,6 +195,7 @@ public override bool Execute()
186195
context.FileNamingOptions.NamespaceMode = Enum.TryParse<NamespaceMode>(NamespaceMode, true, out var mode) ? mode : Core.Configuration.NamespaceMode.Folder;
187196
context.ConceptualDocsEnabled = ConceptualDocsEnabled;
188197
context.ShowPlaceholders = ShowPlaceholders;
198+
context.HasMintlifyTemplate = HasMintlifyTemplate;
189199

190200
// Add the validated documentation references
191201
foreach (var reference in documentationReferences)
@@ -333,15 +343,21 @@ public override bool Execute()
333343
}
334344

335345
// Handle different scenarios based on what we have
336-
if (assemblyPairs.Count == 0 && !hasReferences)
337-
{
338-
Log.LogMessage(MessageImportance.High, "No assemblies or documentation references found. Nothing to process.");
339-
return true;
340-
}
341-
342-
if (assemblyPairs.Count == 0 && hasReferences)
346+
if (assemblyPairs.Count == 0)
343347
{
344-
Log.LogMessage(MessageImportance.High, "📚 Documentation-only mode: Processing DocumentationReferences without local assemblies");
348+
if (hasReferences)
349+
{
350+
Log.LogMessage(MessageImportance.High, "📚 Documentation-only mode: Processing DocumentationReferences without local assemblies");
351+
}
352+
else if (HasMintlifyTemplate)
353+
{
354+
Log.LogMessage(MessageImportance.High, "📄 Template mode: Generating docs.json from MintlifyTemplate without assemblies");
355+
}
356+
else
357+
{
358+
Log.LogMessage(MessageImportance.High, "No assemblies, documentation references, or template found. Nothing to process.");
359+
return true;
360+
}
345361
}
346362

347363
// Process all assemblies together to properly merge navigation

src/CloudNimble.DotNetDocs.Sdk/Sdk/Sdk.targets

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,32 @@
7878
</CloudNimble.DotNetDocs.Sdk.Tasks.DiscoverDocumentedProjectsTask>
7979

8080
<Message Text="📚 Found @(DocumentedProjects->Count()) documented projects for documentation" Importance="high" />
81-
81+
8282
<!-- Show the list of projects that will be documented -->
8383
<ItemGroup>
8484
<_ProjectNames Include="@(DocumentedProjects->'%(Filename)')" />
8585
</ItemGroup>
8686
<Message Text=" Projects: @(_ProjectNames, ', ')" Importance="normal" />
8787
</Target>
8888

89+
<!-- Detect if MintlifyTemplate is present - if so, always run the pipeline -->
90+
<Target Name="DetectMintlifyTemplateMode"
91+
Condition="'$(GenerateDocumentation)' == 'true' AND '$(DocumentationType)' == 'Mintlify'"
92+
AfterTargets="DiscoverDocumentedProjects">
93+
94+
<PropertyGroup>
95+
<!-- If MintlifyTemplate (inline XML) or DocsJsonTemplatePath (external file) is defined -->
96+
<HasMintlifyTemplate Condition="'$(MintlifyTemplate)' != '' OR '$(DocsJsonTemplatePath)' != ''">true</HasMintlifyTemplate>
97+
<HasMintlifyTemplate Condition="'$(HasMintlifyTemplate)' == ''">false</HasMintlifyTemplate>
98+
</PropertyGroup>
99+
100+
<Message Text="📄 MintlifyTemplate detected: $(HasMintlifyTemplate)" Importance="high" Condition="'$(HasMintlifyTemplate)' == 'true'" />
101+
</Target>
102+
89103
<!-- Generate documentation from existing assemblies -->
90104
<Target Name="GenerateDocumentation"
91105
Condition="'$(GenerateDocumentation)' == 'true'"
92-
DependsOnTargets="DiscoverDocumentedProjects">
106+
DependsOnTargets="DiscoverDocumentedProjects;DetectMintlifyTemplateMode">
93107
<Message Text="🚀 Generating documentation from existing assemblies..." Importance="high" />
94108

95109
<!-- Extract assembly paths from built projects (only main project assemblies) -->
@@ -134,6 +148,7 @@
134148
SolutionName="$(_SolutionName)"
135149
ConceptualDocsEnabled="$(ConceptualDocsEnabled)"
136150
ShowPlaceholders="$(ShowPlaceholders)"
151+
HasMintlifyTemplate="$(HasMintlifyTemplate)"
137152
ResolvedDocumentationReferences="@(ResolvedDocumentationReference)">
138153
<Output TaskParameter="GeneratedFiles" ItemName="GeneratedDocumentationFiles" />
139154
</CloudNimble.DotNetDocs.Sdk.Tasks.GenerateDocumentationTask>

src/CloudNimble.DotNetDocs.slnx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
<File Path="dotnet.config" />
3232
<File Path="global.json" />
3333
</Folder>
34-
<Folder Name="/Solution Items/Build/">
35-
<File Path="../.github/dependabot.yml" />
36-
<File Path="../.github/workflows/build-and-deploy.yml" />
37-
<File Path="../.github/workflows/pr-validation.yml" />
38-
<File Path="../.github/workflows/README.md" />
39-
</Folder>
4034
<Folder Name="/Solution Items/Specs/">
4135
<File Path="../specs/core-documentation-fixes.md" />
4236
<File Path="../specs/core-documentation-spec.md" />

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<PackageId>$(MSBuildProjectName.Replace('CloudNimble.', ''))</PackageId>
3333
<Product>DotNetDocs</Product>
3434
<AssemblyVersion>1.1.0.0</AssemblyVersion>
35-
<PackageVersion Condition="'$(PackageVersion)' == ''">1.2.0-preview.5</PackageVersion>
35+
<PackageVersion Condition="'$(PackageVersion)' == ''">1.3.0-preview.1</PackageVersion>
3636
<Authors>CloudNimble</Authors>
3737
<Company>CloudNimble, Inc.</Company>
3838
<RpmPackageVendor>CloudNimble</RpmPackageVendor>

0 commit comments

Comments
 (0)