Closed pharmpy-dev-123 closed 2 years ago
astropy
uses directives like this but I don't remember what is the machinery used to extract them. Maybe @jonathansick knows?
.. EXAMPLE START:
Some narrative with code blocks.
.. EXAMPLE END
As for custom directive or Python to R, that is currently out of scope for this repository.
As for custom directive or Python to R, that is currently out of scope for this repository.
I am developing such a custom directive. I would like to use it instead of the one used by default by automodapi.
@pharmpy-dev-123 does sphinx-automodapi hard-code this? I thought it just reproduced whatever was in docstrings, so if you use your custom directive in there it should work?
@astrofrog Haha! You mean there would be a way for me to specify this in the docstrings. Currently, most of my existing docstrings use a declarative Example
section instead of using a Sphinx directive. Let me see what I can do.
@astrofrog I definitely want to keep the Example(s)
sections using declarative doctest blocks. I do not want to write explicit Sphinx directives in there. The question then is whether I can tell Sphinx or this extension to use a custom code-block
for doctest blocks.
@pharmpy-dev-123 that is a good question, but in fact Sphinx-automodapi doesn't actually interpret the docstrings or know about example sections (we just put autodoc directives in the API docs) - often we use a package such as numpydoc or napoleon to render the content of the docstrings - if you are using one of those packages that might be the right place to have an option for what you need.
@astrofrog Makes sense. Thanks!
Is it possible to customize the generated code blocks used for code examples? I want to use my own directive which does some approximate Python to R transpilation of code examples.