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.
This commit is contained in:
James Yeung 2024-09-21 01:11:44 +08:00 committed by GitHub
parent f0c5996cbd
commit 5830d9a601
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 61 deletions

5
.gitignore vendored
View File

@ -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/**/*
components/LocalizedIntellisenseFiles/AntDesign.xml

View File

@ -54,8 +54,6 @@ namespace AntDesign.Docs.Build.CLI.Command
"StateHasChanged"
};
private readonly Type _staticComponentPageType = typeof(IStaticComponentPage);
private readonly IEnumerable<MemberTypes> _supportedMemberTypes = new List<MemberTypes>
{
MemberTypes.Field,
@ -183,47 +181,6 @@ namespace AntDesign.Docs.Build.CLI.Command
{ Constants.ChineseLanguage, new List<DemoComponent>() }
};
// 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<DocumentationAttribute>();
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<DemoItem>() {
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)

View File

@ -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,

View File

@ -1,5 +1,7 @@
{
"navigationFallback": {
"rewrite": "/index.html"
"responseOverrides": {
"404": {
"rewrite": "/index.html"
}
}
}

View File

@ -1,7 +0,0 @@
namespace AntDesign.Docs
{
public interface IStaticComponentPage
{
}
}

View File

@ -2,7 +2,6 @@
@page "/{locale}/components/overview"
@implements IStaticComponentPage
@inject IStringLocalizer L
@inject ILocalizationService LocalizationService
@inject DemoService demoService