Skip to content

Conversation

@jrturton
Copy link
Contributor

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-output and --enable-experimental-markdown-output-manifest flags set.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@jrturton jrturton linked an issue Sep 26, 2025 that may be closed by this pull request
Copy link
Contributor

@d-ronnqvist d-ronnqvist left a 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 public API 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.

import Markdown

/// Performs any markup processing necessary to build the final output markdown
internal struct MarkdownOutputMarkupWalker: MarkupWalker {
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Comment on lines +43 to +46
## Overview
Nothing to see here
Copy link
Contributor

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)

@jrturton jrturton requested a review from d-ronnqvist December 17, 2025 12:11
Copy link
Contributor

@d-ronnqvist d-ronnqvist left a 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.

@d-ronnqvist
Copy link
Contributor

@swift-ci please test

@d-ronnqvist
Copy link
Contributor

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.

@d-ronnqvist
Copy link
Contributor

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit 8a086b6 into swiftlang:main Dec 19, 2025
2 checks passed
jrturton added a commit to jrturton/swift-docc that referenced this pull request Jan 5, 2026
* 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]>
franklinsch pushed a commit that referenced this pull request Jan 9, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs forum discussion Needs to be discussed in the Swift Forums

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLM-accessible output

2 participants