executablebooks / sphinx-exercise

A Sphinx extension for producing exercise and solution directives.
https://ebp-sphinx-exercise.readthedocs.io
MIT License
18 stars 6 forks source link

Generating labels could prepend filename (internally) to create globally unique labels #36

Open mmcky opened 2 years ago

mmcky commented 2 years ago

Describe the problem

When adding in simple examples such as:

```{exercise}
:label: exercise-1

this will cause a warning to be issued if another exercise is labeled the same way in another document. 

This is a pretty common pattern and the `context` should be handeled by the extension. 

The downside is referencing would need to be documented if you want to reference an example from another document such as using `<filename>:example-1` as a standard reference

### Link to your repository or website

_No response_

### Steps to reproduce

1. build a document with the same `label` in two documents
2. build and a warning will be issued such as

```bash
/Users/matthewmckay/repos-collab/continuous_time_mcs/ctmc_lectures/uc_mc_semigroups.md: WARNING: duplicate example label 'example-1', other instance in /Users/matthewmckay/repos-collab/continuous_time_mcs/ctmc_lectures/generators.md

The version of Python you're using

No response

Your operating system

No response

Versions of your packages

No response

Additional context

No response