Skip to content

build(docs): Update api-markdown-documenter to 0.21.0 #25072

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
2676282
WIP: MDAST
Josmithr Jun 4, 2025
6e6606c
refactor: Simplify node "type" pattern
Josmithr Jun 4, 2025
13d5e40
fix: Build
Josmithr Jun 5, 2025
e93fada
tools: Add fence files
Josmithr Jun 6, 2025
b0302fa
WIP: Replace custom rendering
Josmithr Jun 6, 2025
0e2a8e2
WIP: Continue filling in transformation implementations
Josmithr Jun 6, 2025
26f1f5e
fix: TableCell handler
Josmithr Jun 8, 2025
1c038ae
docs: Update API reports
Josmithr Jun 8, 2025
8435ec9
refactor: Simplify LinkNode
Josmithr Jun 8, 2025
101fe78
refactor: Simplify FencedCodeBlockNode
Josmithr Jun 8, 2025
7b65ed1
build: Add dep on `mdast-util-gfm`
Josmithr Jun 8, 2025
47c7fc1
WIP: ToMarkdown
Josmithr Jun 8, 2025
49b7e6a
improvement: Better formatting alignment
Josmithr Jun 8, 2025
0106820
fix: Bold span handling
Josmithr Jun 8, 2025
7907099
fix: FencedCodeBlockNode transform
Josmithr Jun 8, 2025
9da247f
fix: Return type span
Josmithr Jun 8, 2025
5941b90
fix: TableCell child handling
Josmithr Jun 8, 2025
315591a
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 8, 2025
7cc17be
fix: Restore anchor support for Markdown headings
Josmithr Jun 8, 2025
f954c34
fix: Restore anchors for artificial headings
Josmithr Jun 8, 2025
e2f265c
refactor: Cleanup
Josmithr Jun 8, 2025
681213f
fix: Label rendering
Josmithr Jun 8, 2025
9636142
test: Update test output
Josmithr Jun 8, 2025
86730f2
fix: Handle escaped text
Josmithr Jun 8, 2025
bda46ed
refactor: Extract `EscapedTextNode`
Josmithr Jun 8, 2025
27bd7bb
refactor(api-markdown-documenter): Extract escaped text representatio…
Josmithr Jun 8, 2025
480066d
refactor: Promote API
Josmithr Jun 8, 2025
bdbcc36
docs: Add examples
Josmithr Jun 8, 2025
c7526b9
docs: Update README
Josmithr Jun 8, 2025
ff99e3e
refactor: Rename and export transformation functions
Josmithr Jun 8, 2025
e4307c0
build: Add dev dependency on mdast
Josmithr Jun 8, 2025
802cb4f
build: Pre-update API docs build for library changes
Josmithr Jun 8, 2025
f482b4b
refactor: Log instead of failing
Josmithr Jun 8, 2025
da2233c
remove: Unused context properties
Josmithr Jun 8, 2025
eafbbcc
docs: Fix comments
Josmithr Jun 8, 2025
344fc53
docs: Update API reports
Josmithr Jun 9, 2025
527dc69
fix: customTransformations
Josmithr Jun 9, 2025
f97f92e
test: Add tests
Josmithr Jun 9, 2025
512f9ea
test: Clean up tests
Josmithr Jun 9, 2025
7c03419
remove: BlockQuoteNode (unused)
Josmithr Jun 9, 2025
d3ec52f
test: Add tests
Josmithr Jun 9, 2025
abd14af
docs: Update example
Josmithr Jun 9, 2025
3983999
improvement: Better error message
Josmithr Jun 9, 2025
740dacd
Merge branch 'main' into api-markdown-documenter/EscapedText
Josmithr Jun 9, 2025
3513851
Merge branch 'api-markdown-documenter/EscapedText' of https://github.…
Josmithr Jun 9, 2025
f09abeb
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 9, 2025
a418d8f
Merge branch 'main' into api-markdown-documenter/EscapedText
Josmithr Jun 9, 2025
82df5fd
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 9, 2025
4b36817
Merge branch 'main' into api-markdown-documenter/EscapedText
Josmithr Jun 9, 2025
6f11404
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 9, 2025
599b95a
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 9, 2025
8ab9b0d
fix: Tests
Josmithr Jun 10, 2025
c417909
WIP: Escaped text tests
Josmithr Jun 10, 2025
8e9ecf3
remove: Support for escaped text
Josmithr Jun 10, 2025
474b429
docs: Update changelog
Josmithr Jun 10, 2025
5bb89f7
refactor: Don't export
Josmithr Jun 10, 2025
c6e42d8
Merge branch 'main' into api-markdown-documenter/EscapedText
Josmithr Jun 10, 2025
3a97cc4
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 10, 2025
e6d7df7
Merge branch 'api-markdown-documenter/EscapedText' into api-markdown-…
Josmithr Jun 10, 2025
adc7846
merge
Josmithr Jun 10, 2025
7d9b145
build: Remove `hast-util-raw`
Josmithr Jun 10, 2025
b2c40b8
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 10, 2025
7059eee
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 10, 2025
7ef452d
fix: Silly table cell bug
Josmithr Jun 10, 2025
f95189d
docs: Remove duplicate copyright notice
Josmithr Jun 10, 2025
103540b
docs: Remove stale TODO
Josmithr Jun 10, 2025
bbc3bf0
fix: FencedCodeBlock handler
Josmithr Jun 10, 2025
3f358ef
refactor: Remove unnecessary filtering step
Josmithr Jun 11, 2025
3177c46
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 13, 2025
b5e1f30
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 17, 2025
62135de
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jun 27, 2025
90425ea
fix: Accommodate ListNode changes
Josmithr Jun 27, 2025
e480395
docs: Remove TODO
Josmithr Jun 27, 2025
3886186
test: Unit tests
Josmithr Jun 28, 2025
94aa82a
refactor: Span updates
Josmithr Jun 28, 2025
42e7084
style: Formatting
Josmithr Jun 28, 2025
058a27f
test: Fix test
Josmithr Jun 28, 2025
6f2e637
style: Formatting
Josmithr Jun 28, 2025
fba167d
refactor: Inline utility
Josmithr Jun 28, 2025
14e30b4
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 1, 2025
732ed9e
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 1, 2025
9546536
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 18, 2025
82a5fe0
WIP: Support parsing lists from TSDoc
Josmithr Jul 19, 2025
c1fc17b
test: Unit tests
Josmithr Jul 19, 2025
95e974c
docs: TODO
Josmithr Jul 19, 2025
d06bfd8
fix: Handling of soft breaks
Josmithr Jul 19, 2025
3b34f04
docs: TODOs
Josmithr Jul 19, 2025
89c789c
docs: TODO
Josmithr Jul 19, 2025
ea46feb
test: List parsing tests
Josmithr Jul 19, 2025
1ec2a12
fix: Mixed unordered list delimiters
Josmithr Jul 21, 2025
aa3bdab
test: Nested list tests
Josmithr Jul 21, 2025
cc17ebe
test: Fix suite hierarchy
Josmithr Jul 21, 2025
93583d5
fix: Handle soft-wrapping
Josmithr Jul 21, 2025
84abf18
refactor: Line-break trimming on input
Josmithr Jul 21, 2025
80dc28b
remove: Unneeded sanitization step
Josmithr Jul 21, 2025
83ddb6a
refactor: Rename variables + docs
Josmithr Jul 21, 2025
ea5334b
fix: Tests
Josmithr Jul 21, 2025
b3e8917
fix: Adjacent ordered lists with different delimiters
Josmithr Jul 21, 2025
6f812ec
refactor: Dedupe logic
Josmithr Jul 21, 2025
be8cd51
test: Update test data
Josmithr Jul 21, 2025
5ddd305
refactor: Rename function and add docs
Josmithr Jul 21, 2025
7abfcd9
fix: Typo in test data
Josmithr Jul 21, 2025
be93f1e
refactor: Inline
Josmithr Jul 21, 2025
dc01804
docs: Remove unrelated TODO
Josmithr Jul 21, 2025
7b057ce
docs: Update comment
Josmithr Jul 21, 2025
62c5ad7
test: Update test assets
Josmithr Jul 22, 2025
023e66b
test: Update test assets
Josmithr Jul 22, 2025
4e72d0a
docs: Update changelog
Josmithr Jul 22, 2025
e62ba54
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 22, 2025
04c3fcb
Merge branch 'api-markdown-documenter/list-parsing' into api-markdown…
Josmithr Jul 22, 2025
2207747
fix: Bugs in list transformations
Josmithr Jul 22, 2025
7b8212c
fix: Back compat
Josmithr Jul 22, 2025
8db53d0
test: Update test collateral
Josmithr Jul 22, 2025
e4ce003
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 22, 2025
68a7dde
fix(docs): Account for recent changes
Josmithr Jul 22, 2025
76f112f
build: Temporarily update dep
Josmithr Jul 22, 2025
08b301a
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 22, 2025
2c7fffe
build: Revert dep changes
Josmithr Jul 22, 2025
835b417
revert: `docs` changes
Josmithr Jul 22, 2025
86aaa12
revert: Lockfile changes
Josmithr Jul 22, 2025
8bc6cc4
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 22, 2025
f3150ae
docs: Remove duplication from merge
Josmithr Jul 22, 2025
11edcb8
docs: Re-order contents
Josmithr Jul 22, 2025
561cf47
docs: Fix typo
Josmithr Jul 22, 2025
2a221a7
remove: Unneeded type
Josmithr Jul 22, 2025
ec792ec
refactor: Restore existing ordered list increment policy
Josmithr Jul 22, 2025
d0017ea
docs: Fix typo
Josmithr Jul 22, 2025
36aa4b0
docs: Fix typos
Josmithr Jul 22, 2025
cff1cab
docs: Add docs
Josmithr Jul 22, 2025
d5c1a2d
revert: Unrelated changes
Josmithr Jul 22, 2025
313ef20
Merge branch 'api-markdown-documenter/documentation-to-mdast' of http…
Josmithr Jul 22, 2025
224425a
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 23, 2025
3853f5e
test: Add fenced code comment parsing test
Josmithr Jul 23, 2025
e6909e5
fix: Example mutation
Josmithr Jul 23, 2025
cd0dbf4
Merge branch 'main' into api-markdown-documenter/documentation-to-mdast
Josmithr Jul 23, 2025
88e529a
fix: Line spacing
Josmithr Jul 23, 2025
8faedc8
docs: Fix comment
Josmithr Jul 23, 2025
08efc41
docs: Fix typo in example
Josmithr Jul 23, 2025
a2be75d
docs: Longer term work
Josmithr Jul 23, 2025
ba53f8f
Revert "revert: `docs` changes"
Josmithr Jul 23, 2025
5b9e935
refactor: Rename module
Josmithr Jul 23, 2025
78079af
remove: Unused import
Josmithr Jul 23, 2025
1bd0bdc
WIP: Fix admonitions
Josmithr Jul 23, 2025
eaecdd3
fix: Admonitions
Josmithr Jul 23, 2025
739780d
feat: Allow users to specify `mdastToMarkdown` options
Josmithr Jul 23, 2025
119c28f
Merge branch 'api-markdown-documenter/documentation-to-mdast' into do…
Josmithr Jul 23, 2025
ce0e54e
Merge branch 'main' into docs/update-api-markdown-documenter-for-mdas…
Josmithr Jul 29, 2025
8926baf
build: Add type dependency on mdast
Josmithr Jul 29, 2025
53c2f7b
fix: Casing
Josmithr Jul 29, 2025
c009483
improvement: Stronger typing
Josmithr Jul 29, 2025
0699eeb
revert: Unwanted export change
Josmithr Jul 29, 2025
2380b7b
build: Make dev dep
Josmithr Jul 29, 2025
73094ad
Merge branch 'docs/update-api-markdown-documenter-for-mdast-changes' …
Josmithr Jul 29, 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
60 changes: 52 additions & 8 deletions docs/infra/api-markdown-documenter/admonition-node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

//@ts-check
/** @typedef {import("@fluid-tools/api-markdown-documenter").BlockContent} BlockContent */
/** @typedef {import("@fluid-tools/api-markdown-documenter").ToMarkdownContext} ToMarkdownContext */
/** @typedef {import("mdast").BlockContent} MdastBlockContent */
/** @typedef {import("mdast").PhrasingContent} MdastPhrasingContent */
/** @typedef {"note" | "tip" | "info" | "warning" | "danger"} AdmonitionKind */

import { DocumentationParentNodeBase } from "@fluid-tools/api-markdown-documenter";

/**
* The {@link @fluid-tools/api-markdown-documenter#DocumentationNode."type"} of {@link AdmonitionNode}.
*/
export const admonitionNodeType = "Admonition";
import {
blockContentToMarkdown,
DocumentationParentNodeBase,
} from "@fluid-tools/api-markdown-documenter";

/**
* A block of content representing a notice that should be highlighted for the user.
Expand Down Expand Up @@ -48,15 +50,57 @@ export const admonitionNodeType = "Admonition";
export class AdmonitionNode extends DocumentationParentNodeBase {
/**
* @param {BlockContent[]} children - Child node content.
* @param {string} admonitionKind - The kind of admonition. See {@link https://docusaurus.io/docs/markdown-features/admonitions}.
* @param {AdmonitionKind} admonitionKind - The kind of admonition. See {@link https://docusaurus.io/docs/markdown-features/admonitions}.
* @param {string | undefined} title - (Optional) Title text for the admonition.
*/
constructor(children, admonitionKind, title) {
super(children);

this.type = admonitionNodeType;
this.type = "admonition";

this.admonitionKind = admonitionKind;
this.title = title;
}

/**
* Generates Markdown representing a Docusaurus Admonition.
*
* @param {ToMarkdownContext} context - The transformation context.
*
* @returns {MdastBlockContent[]} The Markdown AST representing the admonition.
*/
toMarkdown(context) {
/**
* @type {MdastBlockContent[]}
*/
const transformedChildren = [];
for (const child of this.children) {
// @ts-ignore -- Limitation of using types in JavaScript: we can't explicitly mark `AdmonitionNode` as only containing phrasing content.
transformedChildren.push(...blockContentToMarkdown(child, context));
}

// If the admonition has a title, prepend it to the list of children with the `directiveLabel` property set.
if (this.title !== undefined) {
transformedChildren.unshift({
type: "paragraph",
data: {
directiveLabel: true,
},
children: [
{
type: "text",
value: this.title,
},
],
});
}

return [
{
type: "containerDirective",
name: this.admonitionKind,
children: transformedChildren,
},
];
}
}
23 changes: 11 additions & 12 deletions docs/infra/api-markdown-documenter/api-documentation-layout.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//@ts-check
/** @typedef {import("@fluid-tools/api-markdown-documenter").ApiItem} ApiItem */
/** @typedef {import("@fluid-tools/api-markdown-documenter").ApiItemTransformationConfiguration} ApiItemTransformationConfiguration */
/** @typedef {import("@fluid-tools/api-markdown-documenter").BlockContent} BlockContent */
/** @typedef {import("@fluid-tools/api-markdown-documenter").DocumentationNode} DocumentationNode */

import {
Expand All @@ -14,12 +15,11 @@ import {
CodeSpanNode,
HeadingNode,
LayoutUtilities,
LineBreakNode,
LinkNode,
ParagraphNode,
PlainTextNode,
ReleaseTag,
SectionNode,
SpanNode,
transformTsdoc,
} from "@fluid-tools/api-markdown-documenter";

Expand All @@ -28,9 +28,9 @@ import { AdmonitionNode } from "./admonition-node.mjs";
const customExamplesSectionTitle = "Usage";
const customThrowsSectionTitle = "Error Handling";

const supportDocsLinkSpan = new SpanNode([
const supportDocsLinkParagraph = new ParagraphNode([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewers: Directives in mdast require block content children. All of the spans here have been updated to be paragraphs.

new PlainTextNode("For more information about our API support guarantees, see "),
LinkNode.createFromPlainText(
new LinkNode(
"here",
// Is there a URL that would be relative to the current site? (For development use)
"https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels",
Expand All @@ -42,7 +42,7 @@ const supportDocsLinkSpan = new SpanNode([
* A special use notice for the "@system" tag.
*/
const systemNotice = new AdmonitionNode(
[supportDocsLinkSpan],
[supportDocsLinkParagraph],
/* admonitionKind: */ "warning",
"This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.",
);
Expand All @@ -52,7 +52,7 @@ const systemNotice = new AdmonitionNode(
*/
const sealedNotice = new AdmonitionNode(
[
new SpanNode([
new ParagraphNode([
new PlainTextNode(
'This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.',
),
Expand All @@ -67,7 +67,7 @@ const sealedNotice = new AdmonitionNode(
*/
const inputNotice = new AdmonitionNode(
[
new SpanNode([
new ParagraphNode([
new PlainTextNode(
'This type is "input," meaning that code outside of the library defining it should not read from it. Future versions of this type may add optional members or make typing of members more general.',
),
Expand Down Expand Up @@ -105,19 +105,18 @@ function createSupportNotice(apiItem, isImportable) {
* @param {string} admonitionTitle - Title to display for the admonition.
*/
function createAdmonition(importSubpath, admonitionTitle) {
/** @type {DocumentationNode[]} */
/** @type {BlockContent[]} */
const admonitionChildren = [];
if (isImportable) {
admonitionChildren.push(
new SpanNode([
new ParagraphNode([
new PlainTextNode("To use, import via "),
CodeSpanNode.createFromPlainText(`${packageName}/${importSubpath}`),
new PlainTextNode("."),
]),
LineBreakNode.Singleton,
);
}
admonitionChildren.push(supportDocsLinkSpan);
admonitionChildren.push(supportDocsLinkParagraph);
return new AdmonitionNode(
admonitionChildren,
/* admonitionKind: */ "warning",
Expand Down Expand Up @@ -305,7 +304,7 @@ function createDeprecationNoticeSection(apiItem, config) {

return new AdmonitionNode(
transformedDeprecatedBlockContents,
"Warning",
"warning",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewers: this was technically a bug. We were implicitly working around it by converting the string to lower case in rendering.

"This API is deprecated and will be removed in a future release.",
);
}
106 changes: 0 additions & 106 deletions docs/infra/api-markdown-documenter/custom-renderers.mjs

This file was deleted.

72 changes: 72 additions & 0 deletions docs/infra/api-markdown-documenter/custom-transformations.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

//@ts-check
/** @typedef {import("@fluid-tools/api-markdown-documenter").BlockContent} BlockContent */
/** @typedef {import("@fluid-tools/api-markdown-documenter").ToMarkdownContext} ToMarkdownContext */
/** @typedef {import("mdast").BlockContent} MdastBlockContent */
/** @typedef {import("mdast").RootContent} MdastRootContent */

import {
documentationNodeToHtml,
HtmlRenderer,
TableNode,
} from "@fluid-tools/api-markdown-documenter";
import { AdmonitionNode } from "./admonition-node.mjs";

/**
* Generates Markdown for an {@link AdmonitionNode} using Docusaurus syntax.
*
* @param {AdmonitionNode} admonitionNode - The node to render.
* @param {ToMarkdownContext} context - The transformation context.
*
* @type {import("@fluid-tools/api-markdown-documenter").ToMarkdownTransformation<AdmonitionNode, MdastBlockContent[]>}
*/
export const transformAdmonitionNode = (admonitionNode, context) => {
return admonitionNode.toMarkdown(context);
};

/**
* Type guard for element HAST nodes.
* @param {import("hast").Nodes} node - The node to check.
* @returns {node is import("hast").Element} Whether the node is an element.
*/
function isElement(node) {
return node.type === "element";
}

/**
* Renders a {@link TableNode} using HTML syntax, and applies the desired CSS class to it.
*
* @param {TableNode} tableNode - The node to render.
* @param {ToMarkdownContext} context - The transformation context.
*
* @type {import("@fluid-tools/api-markdown-documenter").ToMarkdownTransformation<TableNode, [MdastBlockContent]>}
*/
export const transformTableNode = (tableNode, context) => {
// Generate HTML AST for the table node.

const htmlTree = documentationNodeToHtml(tableNode, {
startingHeadingLevel: context.headingLevel,
logger: context.logger,
customTransformations: undefined,
});

if (!isElement(htmlTree)) {
throw new Error("Expected an HTML element as output from table node transformation.");
}

htmlTree.properties.class = "table table-striped table-hover";

// Convert the HTML AST to a string.
const htmlString = HtmlRenderer.renderHtml(htmlTree, { prettyFormatting: true });

return [
{
type: "html",
value: htmlString,
},
];
};
Loading
Loading