From 2214b4dfec39eade2a836b30af33cb5760846ca1 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Fri, 6 Oct 2023 14:45:44 +0200 Subject: [PATCH] Fix generation of root file (#1221) --- ChangeLog.md | 1 + src/CommandLine/Commands/GenerateDocCommand.cs | 4 +++- src/Documentation/DocumentationGenerator.cs | 10 +--------- tools/generate_ref_docs.ps1 | 12 ++---------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f0e5893172..06fdfb2329 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 diff --git a/src/CommandLine/Commands/GenerateDocCommand.cs b/src/CommandLine/Commands/GenerateDocCommand.cs index 6139a80ca5..9828378659 100644 --- a/src/CommandLine/Commands/GenerateDocCommand.cs +++ b/src/CommandLine/Commands/GenerateDocCommand.cs @@ -230,7 +230,7 @@ DocumentationWriter CreateDocumentationWriter(DocumentationContext context) WriteLine($"Generate documentation to '{Options.Output}'", Verbosity.Minimal); - IEnumerable results = generator.Generate(heading: Options.Heading, cancellationToken); + IEnumerable results = generator.Generate(cancellationToken); if (DocumentationHost == DocumentationHost.Sphinx) { @@ -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 results) diff --git a/src/Documentation/DocumentationGenerator.cs b/src/Documentation/DocumentationGenerator.cs index 66a36642c7..0827f87ee5 100644 --- a/src/Documentation/DocumentationGenerator.cs +++ b/src/Documentation/DocumentationGenerator.cs @@ -151,20 +151,12 @@ private DocumentationWriter CreateWriter(ISymbol currentSymbol = null) return writer; } - public IEnumerable Generate(string heading = null, CancellationToken cancellationToken = default) + public IEnumerable 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 typeSymbols = DocumentationModel.Types.Where(f => !Options.ShouldBeIgnored(f)); diff --git a/tools/generate_ref_docs.ps1 b/tools/generate_ref_docs.ps1 index fc9cc3e81f..e84860eddd 100644 --- a/tools/generate_ref_docs.ps1 +++ b/tools/generate_ref_docs.ps1 @@ -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"