Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Auto-record the release and version values into the known words list #224

Open
webknjaz opened this issue Apr 4, 2024 · 3 comments

Comments

@webknjaz
Copy link
Member

webknjaz commented Apr 4, 2024

In my projects, the version is generated with setuptools-scm and thus is derived from Git. For non-tagged commits this means that it has a local specifier part (per PEP 440) which contains a short commit SHA among other things. Like this: 10.0.1.dev100+gf84df246 — it makes sphinxcontrib-spelling complain about dev, gf and df not being words.

The version is rendered through an RST substitution as in |release|. So I can't do

:spelling:ignore:`|release|`

because then, the substitution doesn't work since the role doesn't interpret it.
Similarly, the following doesn't work either:

.. spelling::

   |release|

because the substitution isn't interpreted.

So the ideal solution for this specific problem would be for the extension to auto-learn the version "word".

A more flexible/generic solutions could include:

  1. interpreting RST within directive and role params
  2. having a configuration option with a word list (not in a separate file!) — it could be populated dynamically right in conf.py

I suppose using a custom spelling_filters = [VersionFilter] can be my workaround (though I haven't yet managed to make it work!) but this interface is not really ergonomic — making a class and a method to make just one comparison seems excessive. Even a regular callable with a signature like (str) -> bool would be much cleaner.

webknjaz added a commit to webknjaz/cheroot that referenced this issue Apr 8, 2024
Otherwise, `sphinxcontrib.spelling` would complain about `dev` and
two/three-letter local version identifier segments as misspelled[[1]].

[1]: sphinx-contrib/spelling#224
webknjaz added a commit to webknjaz/cheroot that referenced this issue Apr 8, 2024
Otherwise, `sphinxcontrib.spelling` would complain about `dev` and
two/three-letter local version identifier segments as misspelled[[1]].

[1]: sphinx-contrib/spelling#224
webknjaz added a commit to webknjaz/cheroot that referenced this issue Apr 8, 2024
Otherwise, `sphinxcontrib.spelling` would complain about `dev` and
two/three-letter local version identifier segments as misspelled[[1]].

[1]: sphinx-contrib/spelling#224
webknjaz added a commit to webknjaz/cheroot that referenced this issue Apr 8, 2024
Otherwise, `sphinxcontrib.spelling` would complain about `dev` and
two/three-letter local version identifier segments as misspelled[[1]].

[1]: sphinx-contrib/spelling#224
@webknjaz
Copy link
Member Author

As a workaround for myself, I managed to hack together a custom filter that's hooked to one of the Sphinx's events and is set before the sphinxcontrib-spelling extension loads: cherrypy/cheroot@d76e62a7.

@dhellmann
Copy link
Member

I don't remember why the interface is a class. It looks like it inherits from something in enchant, so I was probably just trying to be consistent with that.

Are you interested in contributing the version filter to this package?

@webknjaz
Copy link
Member Author

Maybe someday, if I have time. Meanwhile, I discovered that using the spelling_filters setting breaks Sphinx cache unpickling, it seems:

WARNING: cannot cache unpickable configuration value: 'spelling_filters' (because it contains a function, class, or module object) [config.cache]

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

No branches or pull requests

2 participants