From 5830d9a6010515aa006190ca618aecde70e12129 Mon Sep 17 00:00:00 2001 From: James Yeung Date: Sat, 21 Sep 2024 01:11:44 +0800 Subject: [PATCH] docs: fix component descption generate (#4219) * docs: fix component descption generate * fix * fix the url rewrite of azrure static webapp * fix build * fix js import * remove the doc dir from gitignore * test doc files * fix path * Revert "fix js import" This reverts commit f87f532c4476b184a797b4f6b4b0043aa4bd0132. --- .gitignore | 5 +- .../Command/GenerateDemoJsonCommand.cs | 49 ++----------------- .../GenerateApiDocumentation.cs | 2 +- .../staticwebapp.config.json | 6 ++- site/AntDesign.Docs/IStaticComponentPage.cs | 7 --- .../Pages/Static/Components/Overview.razor | 1 - 6 files changed, 9 insertions(+), 61 deletions(-) delete mode 100644 site/AntDesign.Docs/IStaticComponentPage.cs diff --git a/.gitignore b/.gitignore index a7132ace..9a84b772 100644 --- a/.gitignore +++ b/.gitignore @@ -362,7 +362,4 @@ scripts/previewEditor/index.html site/AntDesign.Docs/wwwroot/color.less .history /components/LocalizedIntellisenseFiles/AntDesign.xml -components/LocalizedIntellisenseFiles/AntDesign.xml - -# Documentation is automatically generated by XML comments now -site/AntDesign.Docs/Demos/Components/**/doc/**/* \ No newline at end of file +components/LocalizedIntellisenseFiles/AntDesign.xml diff --git a/site/AntDesign.Docs.Build.CLI/Command/GenerateDemoJsonCommand.cs b/site/AntDesign.Docs.Build.CLI/Command/GenerateDemoJsonCommand.cs index a88426de..8388a4e0 100644 --- a/site/AntDesign.Docs.Build.CLI/Command/GenerateDemoJsonCommand.cs +++ b/site/AntDesign.Docs.Build.CLI/Command/GenerateDemoJsonCommand.cs @@ -54,8 +54,6 @@ namespace AntDesign.Docs.Build.CLI.Command "StateHasChanged" }; - private readonly Type _staticComponentPageType = typeof(IStaticComponentPage); - private readonly IEnumerable _supportedMemberTypes = new List { MemberTypes.Field, @@ -183,47 +181,6 @@ namespace AntDesign.Docs.Build.CLI.Command { Constants.ChineseLanguage, new List() } }; - // recognize components by component attribute - var docsStaticComponents = Assembly.Load(DocsAssemblyName).GetTypes().Where(x => x != _staticComponentPageType && x.IsAssignableTo(_staticComponentPageType)); - foreach (var component in docsStaticComponents) - { - var docAttribute = component.GetCustomAttribute(); - if (docAttribute is null) - { - continue; - } - - var componentName = GetNameWithoutGenerics(component); - var title = docAttribute.Title ?? componentName; - - var staticComponent = new DemoComponent() - { - Category = docAttribute.Category.ToString(), - Title = title, - SubTitle = docAttribute.SubTitle, - Type = docAttribute.Type.ToString(), - Desc = string.Empty, - ApiDoc = string.Empty, - Cols = docAttribute.Columns, - Cover = docAttribute.CoverImageUrl, - DemoList = new List() { - new() - { - Order = 0, - Name = componentName, - Title = title, - Description = string.Empty, - Type = component.Namespace.Replace(DocsAssemblyName + ".", string.Empty) + "." + component.Name, - Style = "", - Docs = true, - Debug = false - } - } - }; - componentsDocsByLanguage[Constants.EnglishLanguage].Add(staticComponent); - componentsDocsByLanguage[Constants.ChineseLanguage].Add(staticComponent); - } - var libraryComponents = _libraryAssembly.GetTypes().Where(x => x.GetType() != _componentBaseType); foreach (var component in libraryComponents) { @@ -342,7 +299,7 @@ namespace AntDesign.Docs.Build.CLI.Command private string GetFaqDocs(string componentName, string language) { - var faqFile = new FileInfo(Path.Join(_demoDirectory, $"Components\\{componentName}\\faq.{language}.md")); + var faqFile = new FileInfo(Path.Combine(_demoDirectory, "Components", componentName, $"faq.{language}.md")); if (faqFile.Exists) { var faqFileContent = File.ReadAllText(faqFile.FullName); @@ -354,7 +311,7 @@ namespace AntDesign.Docs.Build.CLI.Command private string GetComponentDocs(string componentName, string language) { - var componentFile = new FileInfo(Path.Join(_demoDirectory, $"Components\\{componentName}\\doc\\index.{language}.md")); + var componentFile = new FileInfo(Path.Combine(_demoDirectory, "Components", componentName, "doc", $"index.{language}.md")); if (componentFile.Exists) { var faqFileContent = File.ReadAllText(componentFile.FullName); @@ -362,7 +319,7 @@ namespace AntDesign.Docs.Build.CLI.Command return docData.desc; } - return null; + return componentFile.FullName; } private string GetMemberXmlName(MemberInfo member) diff --git a/site/AntDesign.Docs.Build.CLI/Documentations/GenerateApiDocumentation.cs b/site/AntDesign.Docs.Build.CLI/Documentations/GenerateApiDocumentation.cs index 5e27503c..a3771f55 100644 --- a/site/AntDesign.Docs.Build.CLI/Documentations/GenerateApiDocumentation.cs +++ b/site/AntDesign.Docs.Build.CLI/Documentations/GenerateApiDocumentation.cs @@ -72,7 +72,7 @@ namespace AntDesign.Docs.Build.CLI.Documentations Title = title, SubTitle = docAttribute.SubTitle, Type = docAttribute.Type.ToString(), - Desc = componentSummary[language], + Desc = componentSummary[language] ?? "no description", ApiDoc = allApiDocumentation.ToString(), Cols = docAttribute.Columns, Cover = docAttribute.CoverImageUrl, diff --git a/site/AntDesign.Docs.Wasm/staticwebapp.config.json b/site/AntDesign.Docs.Wasm/staticwebapp.config.json index 9d62611d..e5a2a5b6 100644 --- a/site/AntDesign.Docs.Wasm/staticwebapp.config.json +++ b/site/AntDesign.Docs.Wasm/staticwebapp.config.json @@ -1,5 +1,7 @@ { - "navigationFallback": { - "rewrite": "/index.html" + "responseOverrides": { + "404": { + "rewrite": "/index.html" + } } } \ No newline at end of file diff --git a/site/AntDesign.Docs/IStaticComponentPage.cs b/site/AntDesign.Docs/IStaticComponentPage.cs deleted file mode 100644 index ede75549..00000000 --- a/site/AntDesign.Docs/IStaticComponentPage.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace AntDesign.Docs -{ - public interface IStaticComponentPage - { - - } -} diff --git a/site/AntDesign.Docs/Pages/Static/Components/Overview.razor b/site/AntDesign.Docs/Pages/Static/Components/Overview.razor index a95942d8..643233ce 100644 --- a/site/AntDesign.Docs/Pages/Static/Components/Overview.razor +++ b/site/AntDesign.Docs/Pages/Static/Components/Overview.razor @@ -2,7 +2,6 @@ @page "/{locale}/components/overview" -@implements IStaticComponentPage @inject IStringLocalizer L @inject ILocalizationService LocalizationService @inject DemoService demoService