-
Notifications
You must be signed in to change notification settings - Fork 553
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
Changes from all commits
2676282
6e6606c
13d5e40
e93fada
b0302fa
0e2a8e2
26f1f5e
1c038ae
8435ec9
101fe78
7b65ed1
47c7fc1
49b7e6a
0106820
7907099
9da247f
5941b90
315591a
7cc17be
f954c34
e2f265c
681213f
9636142
86730f2
bda46ed
27bd7bb
480066d
bdbcc36
c7526b9
ff99e3e
e4307c0
802cb4f
f482b4b
da2233c
eafbbcc
344fc53
527dc69
f97f92e
512f9ea
7c03419
d3ec52f
abd14af
3983999
740dacd
3513851
f09abeb
a418d8f
82df5fd
4b36817
6f11404
599b95a
8ab9b0d
c417909
8e9ecf3
474b429
5bb89f7
c6e42d8
3a97cc4
e6d7df7
adc7846
7d9b145
b2c40b8
7059eee
7ef452d
f95189d
103540b
bbc3bf0
3f358ef
3177c46
b5e1f30
62135de
90425ea
e480395
3886186
94aa82a
42e7084
058a27f
6f2e637
fba167d
14e30b4
732ed9e
9546536
82a5fe0
c1fc17b
95e974c
d06bfd8
3b34f04
89c789c
ea46feb
1ec2a12
aa3bdab
cc17ebe
93583d5
84abf18
80dc28b
83ddb6a
ea5334b
b3e8917
6f812ec
be8cd51
5ddd305
7abfcd9
be93f1e
dc01804
7b057ce
62c5ad7
023e66b
4e72d0a
e62ba54
04c3fcb
2207747
7b8212c
8db53d0
e4ce003
68a7dde
76f112f
08b301a
2c7fffe
835b417
86aaa12
8bc6cc4
f3150ae
11edcb8
561cf47
2a221a7
ec792ec
d0017ea
36aa4b0
cff1cab
d5c1a2d
313ef20
224425a
3853f5e
e6909e5
cd0dbf4
88e529a
8faedc8
08efc41
a2be75d
ba53f8f
5b9e935
78079af
1bd0bdc
eaecdd3
739780d
119c28f
ce0e54e
8926baf
53c2f7b
c009483
0699eeb
2380b7b
73094ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -14,12 +15,11 @@ import { | |
CodeSpanNode, | ||
HeadingNode, | ||
LayoutUtilities, | ||
LineBreakNode, | ||
LinkNode, | ||
ParagraphNode, | ||
PlainTextNode, | ||
ReleaseTag, | ||
SectionNode, | ||
SpanNode, | ||
transformTsdoc, | ||
} from "@fluid-tools/api-markdown-documenter"; | ||
|
||
|
@@ -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([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for reviewers: Directives in |
||
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", | ||
|
@@ -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.", | ||
); | ||
|
@@ -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.', | ||
), | ||
|
@@ -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.', | ||
), | ||
|
@@ -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", | ||
|
@@ -305,7 +304,7 @@ function createDeprecationNoticeSection(apiItem, config) { | |
|
||
return new AdmonitionNode( | ||
transformedDeprecatedBlockContents, | ||
"Warning", | ||
"warning", | ||
Josmithr marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.", | ||
); | ||
} |
This file was deleted.
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"; | ||
Josmithr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Convert the HTML AST to a string. | ||
const htmlString = HtmlRenderer.renderHtml(htmlTree, { prettyFormatting: true }); | ||
|
||
return [ | ||
{ | ||
type: "html", | ||
value: htmlString, | ||
}, | ||
]; | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.