Is there a tool to gather DocC documentation catalog as JSON?

i’m looking for something that can collect the contents of a .docc catalog in a single file in a format such as JSON, for example, for swift-markdown, i would want something like this:

[
    {"path": ["Markdown"], "type": "md", "text": "..."},
    {"path": ["Markdown", "BlockDirectives"], "type": "md", "text": "..."},
    ...
]

You could use the SwiftDocC library to read a DocumentationBundle from a DocumentationWorkspace, but is there DocC-specific knowledge/understanding of the catalog that you're interested in encoding in the JSON file? If not, it seems far simpler to just write a generic recursive filesystem walker. For example, see LocalFileSystemDataProvider.buildTree(root:).

edit: Note that catalogs may include large files like zip archives, movies, and images, so bringing the entire catalog into memory at once or into a single file that can't be read incrementally may not scale well.

1 Like