docs: generate a browsable libosrm C++ API reference - #7677
Open
antheducation wants to merge 1 commit into
Open
Conversation
docs/libosrm.md has described the library contract since 2016 by telling readers where each type lives on GitHub -- 'where to find documentation on it' is a list of links to header files. The HTTP and Node.js APIs both have real reference pages on project-osrm.org; the C++ one does not. tools/api-docs/build.py turns the same headers into that reference: python tools/api-docs/build.py It runs Doxygen over the headers docs/libosrm.md points at, and renders the XML with sourcey@3.6.5, fetched on demand via npx. Nothing is added to the C++ build, no dependency is added to the project, and no header is edited -- promote_comments.py works on a throwaway copy under build/, promoting the // prose that already sits above a declaration to /// so Doxygen reads it. That transform is line-preserving, so every symbol still links to the exact line of the real header at the commit being documented. Output for e9abd4e is published at https://project-osrm.org/libosrm-api/ (58 pages, 421 symbols, 355 source links). docs/libosrm.md and the README now point at it.
Author
|
Companion PR that publishes the rendered output on the site: Project-OSRM/project-osrm.github.com#46 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
docs/libosrm.mdis the only documentation the C++ library has, and it documents the contractby telling the reader where to go and look:
…followed by a bullet list in which
EngineConfig,OSRM,Status,TableParameters,BaseParameters,CoordinateandJSONare each a hyperlink to a header file on GitHub. Thatstructure has been in place since #3441 in December 2016.
Meanwhile the HTTP API and the Node.js API each have a real reference page on project-osrm.org.
An embedder who wants to know what
RouteParameters::annotationsaccepts, or whatStatusdistinguishes, ends up reading
include/engine/api/route_parameters.hppin a browser tab.What this adds
tools/api-docs/build.py— one command that turns those same headers into a reference:python tools/api-docs/build.py # -> build/api-docs/siteFor the pinned commit that is 58 pages covering 421 symbols, with 355 links back to the exact
file and line each symbol was read from. The output is published by the companion PR at
https://project-osrm.org/libosrm-api/ — on the project's own domain, in the repository that
already stores the built documentation for every release from v5.5.0 to v26.6.1.
docs/libosrm.mdand the README's documentation list now point at it. The prose indocs/libosrm.mdis left alone: it explains how the pieces fit together, which a generatedreference is bad at, and it now hands off to the reference for the per-symbol detail, which
prose is bad at.
What it does not do
tools/api-docs/is inert unless you run it.promote_comments.pycopies the headers intobuild/api-docs/srcand promotes the
//prose that already sits above a declaration to///there, becauseDoxygen ignores
//. The transform is line-preserving, so a promoted line keeps its originalnumber and the source links stay true. It is conservative: BSD file banners,
clang-formatand
NOLINTdirectives, and commented-out code are all left alone..github/workflows/. The reference isregenerated when someone runs the command; if you would rather it rebuilt on release
alongside the VitePress docs, I am happy to add that in this PR — I did not want to put an
npxfetch on your pipeline without you asking for it.INPUTintools/api-docs/Doxyfileis exactly the headersdocs/libosrm.mdpoints at plus the types they expose in their signatures. Pointing Doxygenat
include/as a whole would pull in the extractor, partitioner, customizer and internalengine trees, which are not part of what embedders code against.
How it is rendered
Doxygen produces XML only; the pages are rendered from that XML by
Sourcey (
npx --yes sourcey@3.6.5, pinned to an exact version, fetchedon demand — not added to
package.json). Output is plain static HTML with no runtimedependencies, which is why it can be dropped straight into the site repo.
Three things the run turned up, if you want them
resultout-parameter of all sixosrm::OSRMservice methods (Route,Table,Nearest,Match,Trip,Tile) is undocumented, so the reference shows the signaturewithout saying what gets written into it. Six
@param resultlines would fix it.include/osrm/*.hppare alias headers re-exportingengine::api::*, so several types appeartwice in the reference (
osrm::RouteParametersandosrm::engine::api::RouteParameters).Harmless, but a
@copydocor anEXCLUDEline would tidy it.//throughout. If you ever want to drop the pre-pass, converting thepublic headers to
///in place would do it, and would make the comments visible toclangd/IDE tooling as well.
Happy to split this, rename anything, or move the generator wherever you prefer.