-
Notifications
You must be signed in to change notification settings - Fork 536
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
improvement(api-markdown-documenter): Update default suite configuration to leverage new hierarchy options #23602
improvement(api-markdown-documenter): Update default suite configuration to leverage new hierarchy options #23602
Conversation
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.
Copilot reviewed 35 out of 51 changed files in this pull request and generated no comments.
Files not reviewed (16)
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/index.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/index.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testabstractclass-class.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testclass-class.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testemptyinterface-interface.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testenum-enum.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testinterface-interface.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testinterfaceextendingotherinterfaces-interface.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testinterfacewithindexsignature-interface.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testinterfacewithtypeparameter-interface.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testmappedtype-typealias.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testmodule-namespace/index.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testnamespace-namespace/index.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testnamespace-namespace/testclass-class.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testnamespace-namespace/testenum-enum.html: Language not supported
- tools/api-markdown-documenter/src/test/snapshots/html/simple-suite-test/default-config/test-suite-a/testnamespace-namespace/testinterface-interface.html: Language not supported
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
@@ -140,25 +140,25 @@ <h2>Functions</h2> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td><a href="./test-suite-a#testfunction-function">testFunction(testParameter, testOptionalParameter)</a></td> | |||
<td><a href="./test-suite-a/#testfunction-function">testFunction(testParameter, testOptionalParameter)</a></td> |
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.
Does this do the expected thing? Go to the index.md file and then to the testfunction-function anchor?
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.
It does, yeah. That said, it might be better to trim off the trailing slash for /index
cases. Should be an easy enough change to make, so I'll do that before merging.
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.
Could we be explicit and add index.md to the target instead? I'd be even more surprised if things work without that slash in the middle 😆 . I thought it at least made it realize test-suite-a
is a folder, not a file that contain the anchor.
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.
Actually, that makes a bunch of changes to other test cases. I'll put up a separate PR for that change.
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.
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.
Could we be explicit and add index.md to the target instead? I'd be even more surprised if things work without that slash in the middle 😆 . I thought it at least made it realize
test-suite-a
is a folder, not a file that contain the anchor.
For link resolution, I think it ultimately depends on the system being used. This code is trying to target the lowest common denominator. Explicitly including index
might be more reasonable, but I would need to test it.
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.
Alright. Tested. Including index
ends up breaking Docusaurus. And it previously broke Hugo (which is why the special-cased handling for index
was added originally.
Since the link paths are routes rather than file paths (the layer involved here doesn't know what kinds of files are being created, so it has to work on file-agnostic routes) and site generators don't generally create routes for /index
, those links end up being invalid.
Technically, either choice of including or excluding the trailing /
in this case could break a consumer based on their ecosystem. Given this, I'm actually leaning towards preserving the /
in these cases. Preserving it also technically reduces the risk of ambiguity, since the following scenario is possible and technically valid, even if this library won't produce it:
foo.md
foo/index.md
Where /foo
might resolve to foo.md
, and /foo/
might resolve to foo/index.md
.
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.
One question, but otherwise lgtm. I didn't look at the new files in test assets in detail, I'm assuming the content is identical to the one that used to be in other files previously.
case ApiItemKind.Package: { | ||
return getUnscopedPackageName(apiItem as ApiPackage); | ||
return "index"; |
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.
So this bit doesn't impact how the link is rendered, right?
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.
The only change would be from .../foo
to .../foo/
. The default folder-naming policy uses the same getUnscopedPackageName
helper for package items.
The default suite structure has been updated as follows:
-
Package
andNamespace
items now generate documents inside of their own folder hierarchy, yielding documents named "index".-
Enum
andTypeAlias
items now generate their own documents (rather than being rendered as sections under their parent document).E.g., old output would likely look something like
And the new output would likely look more like:
Updates to the
default-config
test assets demonstrate the difference.Also update the
spase-config
test suite to move the package documents under their own hierarchy to be more demonstrative of what an expected use case would likely look like. Other test cases have been updated to maintain existing behavior, accounting for the new defaults.AB#24263