-
Notifications
You must be signed in to change notification settings - Fork 547
refactor(api-markdown-documenter): Update Documentation Domain to be more restrictive #24667
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
refactor(api-markdown-documenter): Update Documentation Domain to be more restrictive #24667
Conversation
Also remove unused static helper on `SectionNode`
…stead of SingleLineDocumentationNode (which is to be removed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR tightens up the Documentation Domain API to enforce Markdown-compatible content hierarchies, updates HTML and TSDoc transformers to use the new node properties, and introduces utilities for table-cell inlining and newline pruning.
- Restrict block vs. phrasing content via
BlockContentMap
/PhrasingContentMap
and update constructors to usetext
/value
properties. - Revise default HTML transformations to consume the new single-child signatures.
- Add
transformTsdocSectionForTableCell
and refine newline-collapse and adjacent-newline filters for more concise tables.
Reviewed Changes
Copilot reviewed 77 out of 77 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tools/api-markdown-documenter/src/documentation-domain/BlockContent.ts | New strict BlockContentMap /BlockContent types |
tools/api-markdown-documenter/src/documentation-domain-to-html/default-transformations | Updated transforms to use node.text and node.value |
tools/api-markdown-documenter/src/documentation-domain-to-html/test | Tests updated to match new single-child constructors |
tools/api-markdown-documenter/src/api-item-transforms/helpers/TableHelpers.ts | Introduced transformTsdocSectionForTableCell |
tools/api-markdown-documenter/src/api-item-transforms/TsdocNodeTransforms.ts | Refactored TSDoc transforms, added newline utilities |
tools/api-markdown-documenter/src/api-item-transforms/helpers/Helpers.ts | Swapped to PhrasingContent /SectionContent maps |
tools/api-markdown-documenter/README.md | Documented new extensibility model |
Comments suppressed due to low confidence (3)
tools/api-markdown-documenter/src/api-item-transforms/helpers/TableHelpers.ts:847
- Add unit tests for
transformTsdocSectionForTableCell
to verify that a single-paragraph section inlines correctly and that multiple-paragraph sections are preserved.
function transformTsdocSectionForTableCell(
tools/api-markdown-documenter/src/api-item-transforms/TsdocNodeTransforms.ts:417
- Add tests for
collapseAdjacentLineBreaks
to ensure consecutive line breaks collapse into a single break as expected.
function collapseAdjacentLineBreaks(nodes: readonly PhrasingContent[]): PhrasingContent[] {
tools/api-markdown-documenter/src/api-item-transforms/TsdocNodeTransforms.ts:481
- Add tests for
filterNewlinesAdjacentToParagraphs
to cover scenarios where line breaks immediately before or after paragraph nodes should be stripped.
function filterNewlinesAdjacentToParagraphs(nodes: readonly BlockContent[]): BlockContent[] {
tools/api-markdown-documenter/src/api-item-transforms/helpers/Helpers.ts
Outdated
Show resolved
Hide resolved
tools/api-markdown-documenter/src/renderers/markdown-renderer/Render.ts
Outdated
Show resolved
Hide resolved
.../src/test/snapshots/html/simple-suite-test/deep-config/test-suite-a/testenum-enum/index.html
Outdated
Show resolved
Hide resolved
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
I haven't had a chance to review the changes yet but I love this direction. Being able to easily tap into the unist ecosystem is powerful. |
Let me know if you want to chat at some point. Happy to bring you up to speed on the current state / planned direction. I'd also be interesting exploring the ability to take TypeDoc's representation as another supported input format. |
Background
The Documentation Domain (
DocumentationNode
and its implementations) was created with a goal of being very flexible in the kinds of trees of content it could express. This was accomplished by, in most cases, allowing parent nodes to contain any kind of child content (with a couple of exceptions). This ultimately ended up creating problems in terms of Markdown-compatibility in particular (HTML is more expressive, so compat there was less of an issue). There are also some forms of hierarchy allowed by the system (and inadvertently used by the system) that don't make sense (e.g., parenting aSectionNode
under aParagraphNode
.As this library has evolved, I have become more and more convinced that the Documentation Domain is unnecessary and should be removed. In this world,
ApiItem
transformations would outputmdast
(Markdown Syntax Trees) directly, instead of going through an intermediary domain.mdast
has a vast support ecosystem, so it seems like a much better target than some bespoke intermediary domain.This PR
This PR is an attempt to begin aligning the Documentation Domain with Markdown syntax requirements by restricting the kinds of contents that can appear under specific kinds of nodes.
It also introduces a new pattern for domain extension, which itself aligns with how the broader
unist
ecosystem accomplishes extensibility. We require this extensibility internally, as ourfluidframework.com
website build actually does extend the Documentation Domain with a custom node type. In the future, this can be trivially mapped to a custommdast
node, but for now we need to support it.Immediate impact
See the updated HTML test assets for the immediate impact on the output format. Note the reduction in unnecessary hierarchy.