Skip to content

Conversation

@Ljon4ik4
Copy link

This PR is an attempt to resolve issue #64 .
This is done by adding a configuration variable proof_uniform_numbering. When it is set to true all numbered proof environments share a counter.

under the hood I have split the type parameter of the node into who parameters, countertype and realtye.
In the default setting, those two agree.
When proof_uniform_numbering = True is set in conf.py, then the countertype of all objects is theorem, i.e. they all share the same counter.

pytest seems to pass, and the uniformly numbered version seems to work fine on the docs.
However, I don't really know how to write python tests, so I could not add tests for the new version.

@Ljon4ik4 Ljon4ik4 marked this pull request as draft December 13, 2025 22:54
@Ljon4ik4 Ljon4ik4 marked this pull request as ready for review December 13, 2025 23:02
@douden
Copy link
Contributor

douden commented Jan 19, 2026

@Ljon4ik4 : Thank you for contributing.

If I read #64 correctly, this PR does it slightly different compared to what the original issue creator intended.

As far as I can deduce from the original issue, the request was that you could "group" the numbering of certain admonitions of this extension, where you could have several different groups sharing the numbering.

Am I correct that your suggestions groups them all together?

@Ljon4ik4
Copy link
Author

@douden Oh yes, sorry - I did not read the issue precisely, you are absolutely right.
The only functionality added here is 'fully consecutive' numbering, not multiple separate ones.

@douden
Copy link
Contributor

douden commented Jan 20, 2026

I looked at your code, and because of the manner you implemented it, I think it could be doable to have the grouped numbering.

Currently I would say that we could reuse the config value you introduced, and if it is a dictionary, you could map each given key to it's corresponding value, where key is the real type and the value is the counter type.

I think that line 42 is the location to expand/adapt for this.

Are you willing to add this functionality?

@Ljon4ik4
Copy link
Author

Yes, thanks a lot - I think that should be possible!
I will try to do it (probably next week), and add it to the PR.

@douden
Copy link
Contributor

douden commented Jan 20, 2026

Yes, thanks a lot - I think that should be possible! I will try to do it (probably next week), and add it to the PR.

Also thanks to you!

Let me know when you changed it, I will then review.

@Ljon4ik4
Copy link
Author

Ljon4ik4 commented Jan 20, 2026

@douden , in the end it was simpler to just pass a dictionary in any case, and just set the dictionary to have a constant value "theorem" for uniform numbering. I think it is built in now...

@douden
Copy link
Contributor

douden commented Jan 21, 2026

Although I agree with the idea of only using a dictionary, the default behavior of the extension now would significantly change.

I think the best would be to

  • Set the default value in docs/source/conf.py to {}
  • In sphinx_proof/__init__.py to rename realtyp_to_countertyp to DEFAULT_REALTYP_TO_COUNTERTYP.
  • Change line 103 to
app.add_config_value("prf_realtyp_to_countertyp", {}, "env")
  • Change line 40 to
countertyp = env.config.prf_realtyp_to_countertyp[realtyp] or DEFAULT_REALTYP_TO_COUNTERTYP[realtyp]

This would allow a user in the conf.py/_config.yml to indicate only which directives should be using a different counter, while all others are untouched.

So if in the config a user sets

prf_realtyp_to_countertyp = {
    "lemma": "theorem",
    "conjecture": "theorem",
    "corollary": "theorem",
    "proposition": "theorem",
    "axiom": "definition",
    "assumption": "definition",
}

The directives lemma, conjecture, corollary and proposition will share the counter with theorem, while axiom and assumption will share the counter with definition. All other directives would use their original counter.

@Ljon4ik4
Copy link
Author

Ah, that's a very good idea!
I implemented it, with a slight variation (the suggested line 40 did not work for me + I had to move the renamed DEFAULT_REALTYP_TO_COUNTERTYP to the file where it is used'')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants