Skip to content

Commit

Permalink
Fix generation of root file (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Oct 6, 2023
1 parent 2bc4356 commit 2214b4d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix [RCS1241](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1241) ([#1197](https://github.com/JosefPihrt/Roslynator/pull/1197)).
- Fix [RCS1250](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1250) ([#1205](https://github.com/JosefPihrt/Roslynator/pull/1205)).
- [CLI] Fix globbing ([#1215](https://github.com/JosefPihrt/Roslynator/pull/1215)).
- [CLI] Fix generation of root file ([#1221](https://github.com/JosefPihrt/Roslynator/pull/1221)).

## [4.5.0] - 2023-08-27

Expand Down
4 changes: 3 additions & 1 deletion src/CommandLine/Commands/GenerateDocCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ DocumentationWriter CreateDocumentationWriter(DocumentationContext context)

WriteLine($"Generate documentation to '{Options.Output}'", Verbosity.Minimal);

IEnumerable<DocumentationGeneratorResult> results = generator.Generate(heading: Options.Heading, cancellationToken);
IEnumerable<DocumentationGeneratorResult> results = generator.Generate(cancellationToken);

if (DocumentationHost == DocumentationHost.Sphinx)
{
Expand Down Expand Up @@ -283,6 +283,8 @@ private void GenerateRootFile(DocumentationGenerator generator)
File.WriteAllText(rootFilePath, result.Content, _defaultEncoding);

WriteLine($"Documentation root successfully generated to '{rootFilePath}'.", Verbosity.Minimal);

generator.Options.RootDirectoryUrl = null;
}

private static void AddTableOfContents(IEnumerable<DocumentationGeneratorResult> results)
Expand Down
10 changes: 1 addition & 9 deletions src/Documentation/DocumentationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,12 @@ private DocumentationWriter CreateWriter(ISymbol currentSymbol = null)
return writer;
}

public IEnumerable<DocumentationGeneratorResult> Generate(string heading = null, CancellationToken cancellationToken = default)
public IEnumerable<DocumentationGeneratorResult> Generate(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();

DocumentationDepth depth = Options.Depth;

using (DocumentationWriter writer = CreateWriter())
{
DocumentationGeneratorResult result = GenerateRoot(writer, heading);

if (result.Content is not null)
yield return result;
}

if (depth <= DocumentationDepth.Namespace)
{
IEnumerable<INamedTypeSymbol> typeSymbols = DocumentationModel.Types.Where(f => !Options.ShouldBeIgnored(f));
Expand Down
12 changes: 2 additions & 10 deletions tools/generate_ref_docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,5 @@ $rootDirectoryUrl="build/ref"
--heading "Roslynator .NET API Reference" `
--group-by-common-namespace `
--ignored-common-parts content `
--ignored-root-parts all `
--max-derived-types 10

& $roslynatorExe generate-doc-root generate_ref_docs.sln `
--properties Configuration=Release `
-o "build/ref.md" `
--host docusaurus `
--heading "Roslynator .NET API Reference" `
--ignored-parts content `
--root-directory-url "ref"
--max-derived-types 10 `
--root-file-path "build/ref.md"

0 comments on commit 2214b4d

Please sign in to comment.