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

feature: Ability to skip files based on globs or regex #20

Closed
nfelt14 opened this issue Apr 23, 2024 · 6 comments · Fixed by #23
Closed

feature: Ability to skip files based on globs or regex #20

nfelt14 opened this issue Apr 23, 2024 · 6 comments · Fixed by #23
Assignees

Comments

@nfelt14
Copy link
Contributor

nfelt14 commented Apr 23, 2024

Is your feature request related to a problem? Please describe.

I have a lot of auto-generated API documentation files that contain lots of words that get flagged as spelling errors, but really should be ignored.

Describe the solution you'd like

I would like to be able to specify a glob or regex to ignore groups of files when spellchecking.

Describe alternatives you've considered

The only workaround is to list each and every file in the skip_files option list, but I am dealing with 600+ files that may need to be ignored.

@pawamoy
Copy link
Owner

pawamoy commented Apr 23, 2024

Hey @nfelt14, thanks for the request 🙂

I agree that it would be nice to be able to ignore files based on globs on regex. Would you like to submit a PR? If you want to go with globs, which I'd prefer, here's how I did it in another project:

    def _expand_inputs(self, inputs: list[str], page_uris: list[str]) -> list[str]:
        expanded: list[str] = []
        for input_file in inputs:
            if "*" in input_file:
                expanded.extend(fnmatch.filter(page_uris, input_file))
            else:
                expanded.append(input_file)
        return expanded

    def on_files(self, files: Files, *, config: MkDocsConfig) -> Files | None:  # noqa: ARG002
        for manpage in self.config.pages:
            manpage["inputs"] = self._expand_inputs(manpage["inputs"], page_uris=list(files.src_uris.keys()))
        return files

This code should be updated to fit mkdocs-spellcheck configuration of course 🙂

The advantage of this approach is that we don't read the disk, and rather use the file objects collected by MkDocs, therefore supporting dynamically generated files that don't even exist in the docs folder.

@nfelt14
Copy link
Contributor Author

nfelt14 commented Apr 23, 2024

If I can find the time to work on it, I will let you know.

nfelt14 added a commit to nfelt14/mkdocs-spellcheck that referenced this issue Apr 30, 2024
…dcard pattern matching

Also updates `skip_files` to treat file paths as OS-agnostic.

Issue pawamoy#21: pawamoy#21
Issue pawamoy#20: pawamoy#20
@nfelt14
Copy link
Contributor Author

nfelt14 commented Apr 30, 2024

@pawamoy I was able to get a PR up for this.

pawamoy pushed a commit that referenced this issue May 5, 2024
@nfelt14
Copy link
Contributor Author

nfelt14 commented May 6, 2024

@pawamoy, any idea when a new release with this feature will be available?

@pawamoy
Copy link
Owner

pawamoy commented May 6, 2024

Later today 👍

@pawamoy
Copy link
Owner

pawamoy commented May 6, 2024

v1.1.0 released 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants