question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autodoc (sphinx.ext.autodoc) cannot be used in a .md file

See original GitHub issue

I wanted to use the Sphinx autodoc module. I made it work in .rst files, but I failed to add autogenerated API documentation to a .md file.

In my _config.yml, I have

sphinx:
  extra_extensions:
    - 'sphinx.ext.autodoc'

In a .rst file, I can write

.. automodule:: amqcfg
    :members: generate

To Reproduce

Add a .md file with content translated from the .rst file.

I am unsure of correct syntax, so I tried twice

first attempt

```{automodule} amqcfg
members: generate
```

renders as

.. py:module:: amqcfg

members: generate

second attempt

```{automodule} amqcfg
---
members: generate
---
```

gives build warning

# PYTHONPATH=`pwd` jupyter-book build docs
Running Sphinx v2.4.4
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] api                                                                                                                                
/mnt/YamlConfiger/docs/api.md:63: WARNING: Directive 'automodule': Unknown option: members

---
members: generate
---
looking for now-outdated files... none found
[...]

Expected behavior

I’d like to be able to use the autodoc feature regardless of whether I am writing in .rst or .md.

Environment

  • Python Version: 3.8.2
  • Package versions or output of jupyter-book --version: **Jupyter Book: 0.7.4 **MyST-NB: 0.8.5 **Sphinx Book Theme: 0.0.35 **MyST-Parser: 0.9.1 **Jupyter-Cache: 0.3.0
  • Operating System: Ubuntu Focal

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
B-Noumedemcommented, Jun 16, 2022

I also have the same issue about generating API reference with Jupyter-book. I want to use the API reference as the last chapter of the package documentation. Any updates ? Thanks a lot

2reactions
nickmachairascommented, May 12, 2022

Bumping this issue because it is the earliest mention I can find of setting the absolute path to the module as autodoc requires. Any updates? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

sphinx.ext.autodoc – Include documentation from docstrings
This extension can import the modules you are documenting, and pull in documentation from docstrings in a semi-automatic way. ... For Sphinx (actually,...
Read more >
Autodoc extension support for Markdown output in Sphinx
I would like to generate markdowns with docstrings loaded in it from classes imported via 'autodoc' extension. So far I have used 'recommonmark ......
Read more >
How-To Guides - MyST-Parser - Read the Docs
Use sphinx.ext.autodoc in Markdown files¶. The sphinx.ext.autodoc is currently hard-coded to write rST, and so can not be used as a conventional MyST ......
Read more >
Documentation Guide
Markdown files use the file extension .md . ... sphinx.ext.autodoc for including documentation from docstrings. sphinx.ext.extlinks for shortening links to ...
Read more >
sphinx-all command man page - python3 ...
In order to use autodoc, you need to activate it in conf.py by putting the string 'sphinx.ext.autodoc' into the list assigned to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found