Closed my1e5 closed 3 weeks ago
Thank you @my1e5 for giving doccmd
a go and for making an issue! You are the first known user who is not myself, and I don't have this use case, so all help figuring out what to do is welcome.
What I do is equivalent to:
$ doccmd --language=python --command="mypy" docs/**/*.rst
or
$ doccmd --language=python --command="mypy" docs/**/*.md
Does that solve your use case?
If not, or if you still think that it is best to have doccmd
take a directory - do you think that doccmd
should recursively search for files? With which extensions? (.md
, .rst
, configurable? if, configurable, how would you like to configure that set of file extensions?).
Happy to provide feedback ☺️
So my use case is I have a docs/
folder in my project which I would like to run ruff check
over. Ultimately I'd like to set up a "check-docs" command which I can then run locally and in my CI.
I guess coming to this as a ruff
/mypy
user, I'm used to these tools taking a list of files or directories as an argument.
$ ruff check --help
Run Ruff on the given files or directories (default)
Usage: ruff check [OPTIONS] [FILES]...
Arguments:
[FILES]... List of files or directories to check [default: .]
$ mypy --help
usage: mypy [-h] [-v] [-V] [more options; see below]
[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
Mypy is a program that will type check your Python code.
Pass in any files or folders you want to type check. Mypy will
recursively traverse any provided folders to find .py files:
$ mypy my_program.py my_src_folder
So I think it would feel very natural if doccmd
could be used in a similar fashion.
I don't know much about .rst
files, my docs folder is exclusively .md
files. But I suppose recursively looking for both .rst
and .md
files would be fine? As mypy
does - "Mypy will recursively traverse any provided folders to find .py files:".
I like how mypy
and ruff
both have an exclude
setting you can configure in your pyproject.toml
file. (see https://docs.astral.sh/ruff/settings/#exclude)
[tool.mypy]
exclude = ["tests"]
Maybe doccmd
could have a table for configuring settings in a doccmd.toml
file (I know this is not a Python-exclusive tool), which falls back to pyproject.toml
if that file is not present?
[tool.doccmd]
exclude = ["docs/foo"]
Also I tried
$ doccmd --language=python --command="ruff check" docs/**/*.md
And it seems to only run on the first folder within my docs directory and then the first file within that folder.
EDIT -> Oh, it might be because the ruff check
commnad errors out and then doesn't run on any more files?
Thank you @my1e5 for your comment and your edit. Have you figured out the answer to the question in your edit? If so, is your use case problem resolved (even if the interface is not ideal)?
I found this method which works
$ find docs/ -type f -name "*.md" -exec doccmd --language=python --command="ruff check" {} \;
Some open questions:
.rst
, .md
, .txt
?).gitignore
?)A potential plan for this:
.rst
is given twice, don't run against those files twice / search twice) (done in #209 ).
or ~/
as a directory works.gitignore
(now in #214 )@my1e5 doccmd
2024.11.06.1
is now available. This allows you to pass in directories, and has options documented in https://doccmd.readthedocs.io/en/latest/commands.html#doccmd or in doccmd --help
such as --myst-extension
, --exclude
and --max-depth
to configure the recursion.
Please give this a go and leave a comment / create issues.
Found your tool from your comment on the "Apply
ruff
tomarkdown
code blocks" issue. It's really nice! Very interested in adopting it into my workflow.One feature which would be nice is the ability run
doccmd
over a folder. For example, I have adocs/
folder.In fact, do you know how I could run
doccmd
over a directory currently? Without specifying all the files individually?