0

I am using MKdocs to generate HTML from markdown files. I'm trying to generate documentation for a Python API from its docstrings. I'm using sphinx, autodoc, autoapi and sphinx-markdown-builder to generate the markdown files. I then copy the markdown files to the the MKDocs project. I have a index.rst that looks like the following:

API Reference
========================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   mypackagename

My conf.py is:

project = 'My Project Name'
copyright = '2023, Me'
author = 'Myself'
release = '0.9.0'

import os
import sys
sys.path.insert(0, os.path.abspath('../path/to/package'))

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    'sphinx.ext.autodoc'
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']

python_use_unqualified_type_names = True
add_module_names = False

I run the following command to generate the rst files:

sphinx-apidoc -o . ../path/to/package/ -f

And then, I generate the markdown files by running make markdown which gives me the files I need. However, for a number of them, hyperlinks are broken. The ones that are broken are broken because their link looks like "#module-mypackagename.submodule.myclass" when it should be "#mypackagenamesubmodulemyclass". How do I fix this?

mzjn
  • 48,958
  • 13
  • 128
  • 248
saqx1
  • 13
  • 2

0 Answers0