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

Excluding included files from spelling check #204

Open
kondziu opened this issue Feb 15, 2023 · 5 comments
Open

Excluding included files from spelling check #204

kondziu opened this issue Feb 15, 2023 · 5 comments

Comments

@kondziu
Copy link

kondziu commented Feb 15, 2023

Let's say a document includes a file via include or csv-table:

.. include:: data_dump.preformatted.log

.. csv-table::
   :file: data.csv
   :header-rows: 1

Then, the contents are subject to a spellcheck. Some of these should be excluded from spellcheck though, if they include data or program output. But they are apparently always included, even if I list them in spelling_exclude_patterns.

Is there a way to exclude them?

Listing all the words individually in the enclosing document (e.g. with the spelling directive) technically works, but it is impractical because (a) I don't want to exclude checking the spelling of these words from the enclosing document, and (b) it's a big list.

@dhellmann
Copy link
Member

A literal include directive should cause the content to be ignored, but I haven't actually tested that.

There was a similar question about todo directives in #203 where the directive itself is injecting an invalid word into the output. In the cases you present, we may need to do something different to allow the content to be ignored. The builder traverses the parsed document (https://github.com/sphinx-contrib/spelling/blob/master/sphinxcontrib/spelling/builder.py#L217) and looks for specific node types to include. Maybe it needs a way to configure node types to ignore as well, so that they are not traversed.

@kondziu
Copy link
Author

kondziu commented Feb 18, 2023

A literal include directive should cause the content to be ignored, but I haven't actually tested that.

I confirm. I have literalinclude directives, and they are not spellchecked.

Maybe it needs a way to configure node types to ignore as well, so that they are not traversed.

I am not sure what a good solution would be, but from my point of view it'd be easiest to be able to turn the spellchecker off for some section of the content, a la:

.. spelling-stop::

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas lorem. Nunc dapibus tortor vel mi dapibus sollicitudin. Nunc tincidunt ante vitae massa. Aliquam erat volutpat. Etiam dictum tincidunt diam. 

.. include:: file.log

Cras pede libero, dapibus nec, pretium sit amet, tempor quis. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. Morbi leo mi, nonummy eget tristique non, rhoncus non leo.

.. spelling-resume::

Another solution that would work for me would be a directive that skips spelling for entire nodes along the lines of :spelling:ignore:


.. spelling-ignore::

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas lorem. Nunc dapibus tortor vel mi dapibus sollicitudin. Nunc tincidunt ante vitae massa. Aliquam erat volutpat. Etiam dictum tincidunt diam. 

.. spelling-ignore::

    .. include:: file.log

.. spelling-ignore::

    Cras pede libero, dapibus nec, pretium sit amet, tempor quis. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. Morbi leo mi, nonummy eget tristique non, rhoncus non leo.

@kondziu kondziu closed this as completed Feb 18, 2023
@kondziu
Copy link
Author

kondziu commented Feb 18, 2023

Sorry for making a mess, I must have misclicked.

@kondziu kondziu reopened this Feb 18, 2023
dhellmann added a commit to dhellmann/spelling that referenced this issue Feb 18, 2023
Add a test showing that the `only` directive works for ignoring
sections of content that has content that should not be checked.

Addresses sphinx-contrib#204
@dhellmann
Copy link
Member

I did some experimenting in #205, and I think you can use the "only" directive for what you want. Something like

.. only:: html

   .. include:: file.log

dhellmann added a commit to dhellmann/spelling that referenced this issue Feb 18, 2023
Add a test showing that the `only` directive works for ignoring
sections of content that has content that should not be checked.

Addresses sphinx-contrib#204
@LecrisUT
Copy link

Another usecase is for bibliography. In that case another solution would be to ignore all spellchecking in that given directive.

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

3 participants