-
Notifications
You must be signed in to change notification settings - Fork 168
Experimental markdown output #1303
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
Experimental markdown output #1303
Conversation
…ert feature flags
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's a lot to unpack here and I've only had the time to skim thought the code but these are a few things that stand out to me:
-
If this is intended as experimental feature, then it can't add actual
publicAPI because consumers of SwiftDocC would have no way of knowing what API is stable and what is experimental and could still have breaking changes or be removed.If a goal of this API is that clients can use it while it's still experimental then it needs to be marked as SPI (using
@_spi(SomeName)so that those clients make a deliberate decision to use it and acknowledge that it may have breaking changes. -
The added tests follow a pattern not seen elsewhere in the repo. I left some more specific comments about that.
Sources/SwiftDocC/SwiftDocCMarkdownOutput/MarkdownOutputManifest.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Model/MarkdownOutput/Translation/MarkdownOutputSemanticVisitor.swift
Show resolved
Hide resolved
Tests/SwiftDocCTests/Rendering/Markdown/MarkdownOutputTests.swift
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Rendering/Markdown/MarkdownOutputTests.swift
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Test Bundles/MarkdownOutput.docc/MarkdownOutput.symbols.json
Outdated
Show resolved
Hide resolved
Tests/SwiftDocCTests/Test Bundles/MarkdownOutput.docc/MarkdownOutput.symbols.json
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Model/Rendering/RenderNode/RenderMetadata.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Model/MarkdownOutput/Translation/MarkdownOutputMarkdownWalker.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocC/Model/MarkdownOutput/Translation/MarkdownOutputMarkdownWalker.swift
Outdated
Show resolved
Hide resolved
| import Markdown | ||
|
|
||
| /// Performs any markup processing necessary to build the final output markdown | ||
| internal struct MarkdownOutputMarkupWalker: MarkupWalker { |
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.
FYI (not blocking): it's redundant to specify internal here because it's the default access level.
| } | ||
|
|
||
| func consume(markdownManifest: MarkdownOutputManifest) throws { | ||
| let url = targetFolder.appendingPathComponent("\(markdownManifest.title)-markdown-manifest.json", isDirectory: false) |
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.
Question: what's the reason for including the title in the manifest file?
Have I misunderstood that archives would only have a single manifest file?
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 archive will only have a single manifest file, but if you are processing the output of multiple archives this allows you to distinguish them
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.
Wouldn't the caller already know what archive the manifest belongs to based on what archive the manifest file is inside?
Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift
Outdated
Show resolved
Hide resolved
| ## Overview | ||
| Nothing to see here |
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.
nit: This is just noise (and just slightly malformed because the rendered page would have two "Overview" sections)
d-ronnqvist
left a comment
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 continues to be lot of API with a higher access level than what's needed and a handful of unused API.
|
@swift-ci please test |
|
I started a cross-repo test in swiftlang/swift#84510 (comment) to double check that these changes don't impact the rest of the toolchain. |
|
@swift-ci please test |
* Add experimental markdown output flag and pass it through to the convert feature flags * Initial export of Markdown from Article * Initial processing of a type-level symbol * Adds symbol declarations and article reference links * Output tutorials to markdown * Be smarter about removing indentation from within block directives * Baseline for adding new tests for markdown output * Basic test infrastructure for markdown output * Adds symbol link tests to markdown output * Tutoorial code rendering markdown tests * Adding metadata to markdown output * Include package source for markdown output test catalog * Output metadata updates * Adds default availability for modules to markdown export * Move availability out of symbol and in to general metadata for markdown output * Refactor markdown output so the final node type is standalone * Add generated markdown flag to render node metadata * Only include unavailable in markdown header if it is true * Initial setup of manifest output, no references * Output of manifest / relationships * Manifest output format updates * Remove member symbol relationship * More compact availability, deal with metadata availability for symbols * Update tests so all inputs are locally defined * Remove print statements from unused visitors * Added snippet handling * Remove or _spi-hide new public API * Remove or _spi-hide new public API (part 2) * Prevent recursion when the abstract of a link contains a link and we are rendering links-with-abstracts * Test and temporary fix for colspan issue swiftlang/swift-markdown#238 * Remove separate SwiftDocCMarkdownOutput target * Bump swift-markdown, remove temporary bug fix * Updates to handle removed bundle parameter * Extract common writer code into a helper function * Clarify use of article.md in test catalog * Deal with internal links with anchor tags * Deal with unresolved symbol links * Updates to improve public API / clarity of MarkdownOutputNode * Improve public API of manifest, sort contents before writing to prevent unneccessary diffs on re-run * Don't use unstructured `Data` for WritableMarkdownOutputNode * Reduce public SPI surface around markdown writing * Make relationship subtype a specific type rather than a string * Make it clear that path component is a fallback title, harden linked list rendering * Add todos and missing tests * Move markdown output types from public SPI to package * don't include scheme or host in documentation links * Reformat multi-condition if statements * remove whitespace-only change * Remove unused declaration * Remove redundant return types * Remove MarkdownOutputNodeTranslator * Add TODO for alternate declarations * Add TODO for structural review * Add stacks todo, set writable type back to package * uri -> identifier * Use RelationshipsGroup.Kind instead of creating a mirror type * Lower access level of manifest, remove children method * Restrict package level declarations to those actually used at package level * Merging main --------- Co-authored-by: Richard Turton <[email protected]>
* Add experimental markdown output flag and pass it through to the convert feature flags * Initial export of Markdown from Article * Initial processing of a type-level symbol * Adds symbol declarations and article reference links * Output tutorials to markdown * Be smarter about removing indentation from within block directives * Baseline for adding new tests for markdown output * Basic test infrastructure for markdown output * Adds symbol link tests to markdown output * Tutoorial code rendering markdown tests * Adding metadata to markdown output * Include package source for markdown output test catalog * Output metadata updates * Adds default availability for modules to markdown export * Move availability out of symbol and in to general metadata for markdown output * Refactor markdown output so the final node type is standalone * Add generated markdown flag to render node metadata * Only include unavailable in markdown header if it is true * Initial setup of manifest output, no references * Output of manifest / relationships * Manifest output format updates * Remove member symbol relationship * More compact availability, deal with metadata availability for symbols * Update tests so all inputs are locally defined * Remove print statements from unused visitors * Added snippet handling * Remove or _spi-hide new public API * Remove or _spi-hide new public API (part 2) * Prevent recursion when the abstract of a link contains a link and we are rendering links-with-abstracts * Test and temporary fix for colspan issue swiftlang/swift-markdown#238 * Remove separate SwiftDocCMarkdownOutput target * Bump swift-markdown, remove temporary bug fix * Updates to handle removed bundle parameter * Extract common writer code into a helper function * Clarify use of article.md in test catalog * Deal with internal links with anchor tags * Deal with unresolved symbol links * Updates to improve public API / clarity of MarkdownOutputNode * Improve public API of manifest, sort contents before writing to prevent unneccessary diffs on re-run * Don't use unstructured `Data` for WritableMarkdownOutputNode * Reduce public SPI surface around markdown writing * Make relationship subtype a specific type rather than a string * Make it clear that path component is a fallback title, harden linked list rendering * Add todos and missing tests * Move markdown output types from public SPI to package * don't include scheme or host in documentation links * Reformat multi-condition if statements * remove whitespace-only change * Remove unused declaration * Remove redundant return types * Remove MarkdownOutputNodeTranslator * Add TODO for alternate declarations * Add TODO for structural review * Add stacks todo, set writable type back to package * uri -> identifier * Use RelationshipsGroup.Kind instead of creating a mirror type * Lower access level of manifest, remove children method * Restrict package level declarations to those actually used at package level * Merging main --------- Co-authored-by: Richard Turton <[email protected]>
Issue #1301
Summary
This PR addresses the changes proposed in #1301. It involves a new translator / semantic visitor / markup walker to create the new outputs from
DocumentationNode. This is done for each node, after the render JSON is generated.Dependencies
None
Testing
There are extensive unit tests in
MarkdownOutputTests.swift. Testers can also run the convert command against any catalog with the--enable-experimental-markdown-outputand--enable-experimental-markdown-output-manifestflags set.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded