Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(docs): Update api-markdown-documenter and utilize new hierarchy options #23504

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
db9d9f1
WIP
Josmithr Dec 16, 2024
f80e4a6
chore: Add `DeepRequired` utility type
Josmithr Dec 16, 2024
ec1242f
chore: Type aliases and helper functions
Josmithr Dec 16, 2024
410049c
[WIP]
Josmithr Dec 16, 2024
9d3ecb2
style: Prettier
Josmithr Dec 16, 2024
b8c8f83
WIP
Josmithr Dec 17, 2024
a67cf98
More WIP
Josmithr Dec 18, 2024
964e4bf
docs: Fix comments
Josmithr Dec 18, 2024
600591a
fix: Correct handling of entry-points
Josmithr Dec 18, 2024
571c170
fix: Types
Josmithr Dec 18, 2024
63f253d
refactor: Rename interface
Josmithr Dec 18, 2024
824c7f0
fix: End-to-end tests
Josmithr Dec 18, 2024
cf91dc5
fix: Config generation
Josmithr Dec 18, 2024
3019028
refactor: Rename types
Josmithr Dec 18, 2024
dad5814
refactor: Rename file
Josmithr Dec 18, 2024
81994f4
fix: Restore support for document hierarchy for packages
Josmithr Dec 18, 2024
214ae3b
fix: Test configs
Josmithr Dec 18, 2024
9786a34
fix(test): Fix configurations
Josmithr Dec 18, 2024
8bce322
refactor: Move function
Josmithr Dec 18, 2024
fda21fa
test: Remove invalid test case
Josmithr Dec 18, 2024
3071431
fix: Document and folder naming
Josmithr Dec 18, 2024
60f6e74
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 19, 2024
3e67819
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 19, 2024
e58de30
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 19, 2024
ef12ea3
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 19, 2024
7206e37
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 20, 2024
289c9eb
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 20, 2024
e4f184c
docs: Fix comment
Josmithr Dec 20, 2024
25162b5
refactor: Remove unneeded type alias
Josmithr Dec 20, 2024
92ecd59
docs: Remove obsolete TODO
Josmithr Dec 20, 2024
7e2dbd5
docs: Remove TODOs
Josmithr Dec 20, 2024
1c6e34a
test: Update test structure
Josmithr Dec 20, 2024
2dc2447
remove: Unused utility function
Josmithr Dec 20, 2024
77f96c8
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 20, 2024
56b58e8
test: Add deep config end-to-end tests
Josmithr Dec 20, 2024
5c7d60a
refactor: More hierarchy options flexibility
Josmithr Dec 21, 2024
21b1ea9
refactor: Simplify
Josmithr Dec 21, 2024
ba59e5a
Merge branch 'main' into api-markdown-documenter/hierarchy-config
Josmithr Dec 21, 2024
0381258
refactor: More simplifying
Josmithr Dec 21, 2024
f711e86
refactor: Give more hierarchy config flexibility
Josmithr Jan 6, 2025
42c752b
WIP: Better hierarchical control over naming policy
Josmithr Jan 7, 2025
338e12a
WIP: More input flexibility progress
Josmithr Jan 7, 2025
181c0c8
refactor: Rename properties
Josmithr Jan 7, 2025
9771f71
test: Add unit tests
Josmithr Jan 7, 2025
e6b39dc
refactor: Make input options optional
Josmithr Jan 7, 2025
1db0399
refactor: Variable renames and comment
Josmithr Jan 7, 2025
8119e7f
docs: Add missing copyright notice
Josmithr Jan 7, 2025
ff8de15
test: Add unit test
Josmithr Jan 7, 2025
46364b1
docs: Update comments
Josmithr Jan 7, 2025
0b316fb
docs: Remove stale TODO
Josmithr Jan 7, 2025
05e70b6
refactor: Further simplify hierarchy setup
Josmithr Jan 8, 2025
f840b8e
build(docs): Update API docs build
Josmithr Jan 8, 2025
91e289d
Merge branch 'main' into docs/update-api-markdown-documenter-for-hier…
Josmithr Jan 23, 2025
02bc600
fix: Import
Josmithr Jan 23, 2025
480fe29
revert: Unwanted change
Josmithr Jan 23, 2025
cf59b6f
remove: Duplicated file
Josmithr Jan 23, 2025
fc48322
fix: Local API docs sidebar config
Josmithr Jan 23, 2025
38376ee
refactor: Update config
Josmithr Jan 23, 2025
79dddbf
Merge branch 'main' into docs/update-api-markdown-documenter-for-hier…
Josmithr Jan 23, 2025
a73d734
build: Update dep
Josmithr Jan 23, 2025
663a9e2
docs: Update links
Josmithr Jan 23, 2025
a217ac1
Merge branch 'main' into docs/update-api-markdown-documenter-for-hier…
Josmithr Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ versions.json

# Generated API docs.
# Note: keep `mdx` files that are handwritten
docs/api/*
!docs/api/**/*.mdx
versioned_docs/*/api/*
!versioned_docs/*/api/**/*.mdx
docs/api
!docs/api/index.mdx
versioned_docs/*/api
!versioned_docs/*/api/index.mdx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opted to exclude specific files, rather than blanket-excluding mdx files. This will let us (theoretically) move our API docs to mdx in the future.

!versioned_docs/*/api/fluid-framework/index.mdx

# Test
test-results
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/api/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ sidebar_position: 10

{/* Note: these contents are new and should be reviewed. The current website's API docs landing page has no description about what the packages do / when to use them. It's not very useful. */}

To get started with the Fluid Framework, you'll want to take a dependency on our client library, [fluid-framework](./fluid-framework.md).
To get started with the Fluid Framework, you'll want to take a dependency on our client library, [fluid-framework](./fluid-framework/index.md).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to specify index here because we are expressing these links via file paths rather than routes. This is the recommended pattern.


You'll then want to pair that with the appropriate service client implementation based on your service.
These include:

- [@fluidframework/azure-client](./azure-client.md) (for use with [Azure Fluid Relay](../deployment/azure-fluid-relay.mdx))
- [@fluidframework/odsp-client](./odsp-client.md) (for use with [SharePoint Embedded](../deployment/sharepoint-embedded.mdx))
- [@fluidframework/tinylicious-client](./tinylicious-client.md) (for testing with [Tinylicious](../testing/tinylicious.mdx))
- [@fluidframework/azure-client](./azure-client/index.md) (for use with [Azure Fluid Relay](../deployment/azure-fluid-relay.mdx))
- [@fluidframework/odsp-client](./odsp-client/index.md) (for use with [SharePoint Embedded](../deployment/sharepoint-embedded.mdx))
- [@fluidframework/tinylicious-client](./tinylicious-client/index.md) (for testing with [Tinylicious](../testing/tinylicious.mdx))

For more information on our service client implementations, see [Fluid Services](../deployment/service-options.mdx).
71 changes: 37 additions & 34 deletions docs/infra/api-markdown-documenter/render-api-documentation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ApiItemUtilities,
DocumentationNodeType,
getApiItemTransformationConfigurationWithDefaults,
HierarchyKind,
loadModel,
MarkdownRenderer,
ReleaseTag,
Expand Down Expand Up @@ -78,13 +79,42 @@ export async function renderApiDocumentation(inputDir, outputDir, uriRootDir, ap

const config = getApiItemTransformationConfigurationWithDefaults({
apiModel,
documentBoundaries: [
ApiItemKind.Class,
ApiItemKind.Enum,
ApiItemKind.Interface,
ApiItemKind.Namespace,
ApiItemKind.TypeAlias,
],
hierarchy: {
alexvy86 marked this conversation as resolved.
Show resolved Hide resolved
[ApiItemKind.Model]: HierarchyKind.Document,
[ApiItemKind.Namespace]: HierarchyKind.Folder,
[ApiItemKind.Package]: HierarchyKind.Folder,
Comment on lines +83 to +85
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are the defaults for their respective types, but since we override document naming policy for them, seems reasonable to add them here explicitly to make the relationship clear.

getDocumentName: (apiItem, hierarchyConfig) => {
switch (apiItem.kind) {
case ApiItemKind.Model:
// We inject a custom landing page ("index.mdx") for a curated package reference.
// So we will give the auto-generated / complete model page its own separate document.
return "package-reference";

case ApiItemKind.Namespace:
case ApiItemKind.Package:
// Namespace and package items generate documents within their own folder.
return "index";
default:
let documentName = ApiItemUtilities.createQualifiedDocumentNameForApiItem(
apiItem,
hierarchyConfig,
);

// Docusaurus treats any document name starting with "_" as a "partial" document, which
// will not be included in the site output.
// See: <https://docusaurus.io/docs/create-doc>
// To work around this, while (hopefully) preventing name collisions, we will prefix
// The filename with "u". E.g. `_foo.md` -> `u_foo.md`.
// This doesn't affect displayed contents, strictly changes the resulting filenames and any
// links to them.
if (documentName.startsWith("_")) {
documentName = `u${documentName}`;
}

return documentName;
}
},
},
newlineKind: "lf",
uriRoot: uriRootDir,
includeBreadcrumb: false, // Docusaurus includes this by default based on file hierarchy
Expand All @@ -111,33 +141,6 @@ export async function renderApiDocumentation(inputDir, outputDir, uriRootDir, ap
}
return alerts;
},
getFileNameForItem: (apiItem) => {
switch (apiItem.kind) {
case ApiItemKind.Model: {
return "package-reference";
}
case ApiItemKind.Package: {
return ApiItemUtilities.getUnscopedPackageName(apiItem);
}
default: {
const qualifiedName = ApiItemUtilities.getQualifiedApiItemName(apiItem);
let fileName = qualifiedName;

// Docusaurus treats any document name starting with "_" as a "partial" document, which
// will not be included in the site output.
// See: <https://docusaurus.io/docs/create-doc>
// To work around this, while (hopefully) preventing name collisions, we will prefix
// The filename with "u". E.g. `_foo.md` -> `u_foo.md`.
// This doesn't affect displayed contents, strictly changes the resulting filenames and any
// links to them.
if (qualifiedName.startsWith("_")) {
fileName = `u${qualifiedName}`;
}

return fileName;
}
}
},
skipPackage: (apiPackage) => {
const packageName = apiPackage.displayName;
const packageScope = PackageName.getScope(packageName);
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@docusaurus/tsconfig": "^3.6.2",
"@docusaurus/types": "^3.6.2",
"@easyops-cn/docusaurus-search-local": "^0.45.0",
"@fluid-tools/api-markdown-documenter": "^0.17.2",
"@fluid-tools/api-markdown-documenter": "^0.18.0",
"@fluid-tools/markdown-magic": "file:../tools/markdown-magic",
"@fluidframework/build-common": "^2.0.3",
"@fluidframework/eslint-config-fluid": "^5.5.1",
Expand Down
Loading
Loading