Force Sphinx to interpret Markdown with MyST in Python docstrings instead of reStructuredText

820 Views Asked by At

I'm rookie with Sphinx, and I was trying to figure out how to use MyST parser for sphinx to make it work with .autodoc extension.

I found this thread. I've been trying to convert this code to work with MyST and I failed.

I've been trying to do something like this:

import myst_parser

def docstring(app, what, name, obj, options, lines):
    md  = '\n'.join(lines)
    ast = myst_parser.sphinx_parser.MystParser().parse(md)
    rst = myst_parser.ReStructuredTextRenderer().render(ast)
    lines.clear()
    lines += rst.splitlines()

def setup(app):
    app.connect('autodoc-process-docstring', docstring)

I don't know what else should I pass to parse method. and what to do afterwards (from what I saw myst_parser doesnt have ReStructuredTextRenderer).

Could anyone help me with it? Thx

0

There are 0 best solutions below