decorators for adding api status to class/function docs#991
decorators for adding api status to class/function docs#991David-Baddeley wants to merge 1 commit into
Conversation
Codecov Report
@@ Coverage Diff @@
## master #991 +/- ##
==========================================
- Coverage 11.27% 11.26% -0.01%
==========================================
Files 629 630 +1
Lines 72338 72348 +10
==========================================
- Hits 8154 8151 -3
- Misses 64184 64197 +13
Continue to review full report at Codecov.
|
|
proposed usage: from PYME import apistatus
@apistatus.api
def some_function_we_are_going_to_maintain(...)
# a function that we expect to be used in 3rd party code / plugins
@apistatus.internal
def _my_magic_function(...)
# something that we do not expect to (ever) be called from external code
# NOTE: a leading underscore will always imply @apistatus.internal, whether annotated or not
# but is used for things that are private to a specific module/class, even within PYME. The purpose of
# the decorator is actually for classes/functions which might represent an internal API of sorts -
# i.e. public within PYME, but not recommended for external use. |
|
On the super-long time scale TODO - add a flag to the class/method which alters how APIDoc parses/formats it. |
|
This seems like a good approach. Its presence in the code will already signal to anybody who seriously works on code what the current/intended status is - as this generally needs looking into the source code anyway. If it eventually shows up in docs good, too, but probably less essential then in the code base. Would also remind any core developer touching certain interfaces may require extra care. |
|
I think this is a reasonable middle-ground between writing clear documentation and saying, "it's in the code, good luck". Documentation would eliminate the need for these decorators, but we probably won't document everything anytime soon. We should definitely make sure the meaning of these flags is in the online docs. |
|
@zacsimile - Documentation would not strictly remove the need for the decorators.
|
|
I think this is worth merging. Can we also add a |
|
Major issue with this at present is how sphinx/numpydoc treats docstring sections which don't match it's expectations ... |
|
looks like sphinx-doc/sphinx#8658 might have a solution ... |
In response to #988
Proposed changes:
Currently a bit of a straw-man concept for documenting the API status of various bits of PYME to
a) help writers of 3rd party code determine what is safe to use/call
b) act as mental reminders when maintaining/modifying code when backwards compatibility should be maintained
or there should be a deprecation path.
The decorators will add an
API Statussection to the class/function docstringWould be great to get some feedback on whether this is likely to be useful / make sense.
@csoeller, @barentine, @zacsimile
TODOS:
Probably need to change apidoc/napoleon settings to make it recognize the custom docstring section