Page MenuHomeSoftware Heritage

add the ability to selectively hide (or annotate?) endpoints in the API doc page
Closed, MigratedEdits Locked

Description

Our API doc page currently lists all endpoints present in the Python module that are annotated with the relevant decorator, without any discrimination.
But we are going to open them up selectively, with some of them being part of the code but not deployed in production yet (and hence protected by HTTP auth or other means). We need a way to differentiate these situations.

In particular:

  • some endpoints will be implemented but we do not want their doc to be published on the page
    • → for this we can maybe just comment out the decorators in the code, although that might make the decorator code bitrot over time
  • some endpoints will be implemented and ready, but not exposed and marked as "upcoming" (i'm thinking at endpoints backed by incomplete tables, for instance)
    • → for this it will be nice to have some sort of flashy annotation, like "coming soon", on the API doc page, and everything else typeset normally
    • if this is generic enough, in the future it could be used to also add annotations like "deprecated" to selected methods

Event Timeline

zack moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

A simple approach has been used here to add a parameter hidden to the doc.route decorator (the one currently in charge of displaying the doc on endpoints).
If that parameter 'hidden' is True, return the function without any decorator. The function is thus eliminated from the listing.
Otherwise, decorate as usual, the function then appears in the list.

Two minor nits:

  • the CSS class for tagged API endpoints should not be class="api-doc-route-upcoming", but rather class="api-doc-route api-doc-route-upcoming api-doc-route-other-tag", otherwise writing a decent CSS would be hard
  • also, the tags should appear on the page even for people not using CSS, maybe add a line between the API endpoint name and the docstring, with the tags separated by comma