Integrating library-documentation-action-v2 Functionality into pony-doc #4861
SeanTAllen
started this conversation in
pony-doc
Replies: 1 comment
-
Decision: CLI option for corral project directoryThe Revised CLI option
Validationpony-doc checks for both files at the given path:
No implicit searching (walking up directories to find Reading dependency metadataSame as the action: scan |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
The library-documentation-action-v2 GitHub Action generates documentation for Pony libraries and deploys it to GitHub Pages. It wraps
ponyc --docs(soonpony-doc) with post-processing that filters documentation output to only the library's own packages, resolves cross-references to external documentation, and runsmkdocs build.With pony-doc now replacing
docgen.cas the documentation generator, the filtering and link resolution functionality should move into pony-doc itself. This document specifies what needs to be integrated and how.What library-documentation-action-v2 Does Today
The action takes three inputs:
library_name,docs_build_dir(where generated docs are placed), andsite_url(canonical site URL for mkdocs). Itsentrypoint.pyperforms these steps in order:make docsto generate full documentation (all packages including dependencies){library_name}-)mkdocs.ymlnav entries to only library packages and setssite_urlindex.mdpackage listing to only library packages_corral/{dep}/corral.jsonfiles to build a package-to-documentation-URL mapmkdocs buildto produce the final HTML siteThe action filters at the file level — it generates everything, then deletes what doesn't belong. It determines which package a doc file belongs to by parsing the TQFN filename (splitting on
-, dropping the last segment to get the package name, rejoining with/). This string-splitting heuristic works because Pony type names can't contain dashes, but it's fragile in principle.What Moves Into pony-doc
General (backend-agnostic) — lives in the extractor
Package filtering by library name. When a library name is provided, only packages belonging to that library are included in the
DocProgramIR. A package belongs to the library if its qualified name equals{library_name}or starts with{library_name}/. Dependencies are still compiled (types reference them), but they're excluded from the documentation output.Since filtering happens during extraction, the action's post-processing steps (removing files, trimming nav, trimming index) become unnecessary — the backend never sees the filtered packages and never generates output for them. pony-doc has direct access to each type's package through the AST, so it doesn't need the action's filename-parsing heuristic.
External documentation URL map. pony-doc reads
corral.jsonfiles from the corral workspace (_corral/) to build a mapping from package name to documentation URL. Eachcorral.jsoncontains aninfo.documentation_urlfield and apackagesarray listing the package names that dependency provides. All packages listed in a dependency'scorral.jsonmap to that dependency'sdocumentation_url.The stdlib is not a corral dependency (it's built into ponyc), so it won't appear in any
corral.json. Packages not found in any dependency'scorral.jsondefault tohttps://stdlib.ponylang.io/. This is a best-effort heuristic — it's correct for stdlib packages (the common case), but non-stdlib dependencies that lack acorral.jsonentirely will get incorrect links pointing to stdlib.Note: the action has a bug here. When a dependency's
corral.jsonlists packages but omitsdocumentation_url(or has it as empty string), the action maps those packages to"", producing broken relative links instead of falling back to stdlib. pony-doc fixes this by treating absent or emptydocumentation_urlthe same as "not found" — the stdlib fallback applies.Marking external references. When
--library-nameis active and aDocNominaltype's definition resolves to a package that was filtered out, the nominal is marked as "external" with the appropriate base URL from the documentation URL map. Without--library-name, no packages are filtered out and this logic does not apply.The IR change:
DocNominalgets a newexternal_url: (String | None)field. WhenNone, the type is local and links to a local file. When set, the backend uses it as the base URL for the link.Backend-specific — lives in each backend implementation
Rendering external links. When a
DocNominalhas anexternal_url, the backend renders its link using the external base URL instead of a local file reference. For the mkdocs backend, this means generating[Name](https://external.url/tqfn/)instead of[Name](tqfn.md). External link resolution only applies to type references within entity documentation pages, not to package-level links (which are eliminated by filtering).What Does NOT Move Into pony-doc
site_urlinjection. This is a pure mkdocs configuration concern. It tells mkdocs the canonical site URL for generating correct absolute URLs in HTML output (sitemaps, canonical links, 404 page asset paths). It has no effect on the markdown pony-doc generates. Users set this when they runmkdocs build, not when they run pony-doc.docs_build_dir. This is a build orchestration concern — it tells the action where to find the generated docs. pony-doc already has--outputfor this purpose.Running
mkdocs build. pony-doc generates markdown and configuration; building the final HTML site remains the caller's responsibility.CLI Interface
Two new options:
--library-name NAME— filter packages to only those belonging to the named library. Implies readingcorral.jsonfiles for external link resolution.--corral-dir DIR— path to the corral workspace directory (default:_corralrelative to the package being documented). Only meaningful when--library-nameis set.corral.json Format
For reference, the relevant fields in a
corral.jsonfile:{ "info": { "documentation_url": "https://example.github.io/my-library/" }, "packages": [ "my-library", "my-library/subpackage" ] }documentation_urlmay be absent or empty string — pony-doc treats both as "not found" and applies the stdlib fallback URL (fixing a bug in the action where these cases produce broken relative links)packagesmay be absent — dependencies without it contribute nothing to the URL mapdocumentation_urlmay or may not have a trailing slash — pony-doc normalizes itHow External Link Resolution Works
corral.jsonfilesDocNominal's definition resolves to a package not in the filtered set, set itsexternal_urlfield to the appropriate base URL from the documentation URL mapexternal_url, render the link as{external_url}{tqfn}/instead of{tqfn}.mdThe TQFN-to-URL conversion follows the same pattern the action uses: the TQFN string becomes the URL path segment with a trailing
/(e.g., TQFNsemver-Versionbecomes URL pathsemver-Version/).Beta Was this translation helpful? Give feedback.
All reactions