MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Duplicate label warning from headings in module docstrings

Open anibali opened this issue 8 months ago • 1 comments

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

anibali avatar Nov 21 '23 23:11 anibali

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:

welcome[bot] avatar Nov 21 '23 23:11 welcome[bot]