executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
751 stars 197 forks source link

Duplicate label warning from headings in module docstrings #829

Open anibali opened 11 months ago

anibali commented 11 months ago

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

docutils 0.20.1
sphinx 7.2.6

What operating system are you using?

Linux

Describe the Bug

Consider the use case of including headings in top-level module docstrings. For example:

"""The Foo module.

Introduction
============

Fantastic things await you in the Foo module.

More
----
Some more
"""

Now suppose that there are multiple modules with the same headings in their docstrings. If we attempt to document these modules by using automodule from separate markdown files (via eval-rst), we get "WARNING: duplicate label [...]". This seems to only affect "top-level" headings (e.g., "Introduction" in the above snippet, but not "More"). This warning does not occur when using automodule from .rst files instead of .md files.

Expected Behavior

There should be no "duplicate label" warning.

To Reproduce

  1. Install Sphinx and MyST-Parser
  2. Clone https://github.com/anibali/bug-myst-duplicate-label
  3. Run sphinx-build docs build/html

To see how this issue does not affect .rst files, convert both myproj_bar.md and myproj_foo.md to restructured text. For example, rename myproj_bar.md to myproj_bar.rst and change its content to:

myproj.bar module
=================

.. automodule:: myproj.bar
welcome[bot] commented 11 months ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada: