mdoc icon indicating copy to clipboard operation
mdoc copied to clipboard

Feature request: Support globbing for `--in` paths

Open davesmith00000 opened this issue 4 years ago • 3 comments

Hello!

I'm trying to process > 50 markdown files with mdoc, and generally the experience is excellent.

These are files that were previously unchecked, that are now being checked for the first time, and getting them all up to standard is a slow process, partially because I have a lot of errors(!), but also compiling 50 files takes a long time. To speed things up a bit, I've been using the --in param to single out the file I'm currently working on.

What I'd really like (in lieu of tab completion) is to be able to glob for a file, rather than having to put in the full path (they are quite often several directories deep). For example (sbt):

This:

docs/mdoc --in docs/presentation/lighting.md

Could be something like:

docs/mdoc --in **/lighting.md
``

As you would do with `testOnly` when you want to test a single test suite. I would be quite happy with mdoc choosing the first matching file if there was more than one.

davesmith00000 avatar Oct 09 '21 20:10 davesmith00000

Thank you for reporting! Have you tried the --include and --exclude flags?

  --include [<glob> ...] (default: [])
    Glob to filter which files to process. Defaults to all files. Example: --include
    **/example.md will process only files with the name example.md.

  --exclude [<glob> ...] (default: [])
    Glob to filter which files from exclude from processing. Defaults to no files.
    Example: --include users/**.md --exclude **/example.md will process all
    files in the users/ directory excluding files named example.md.

The --in flag must be a directory since input files get relativized by it.

olafurpg avatar Oct 10 '21 05:10 olafurpg

Also, have you tried the --watch flag? You always pay a base overhead from initializing the compiler if you run mdoc/run on every iterations. With --watch you get the fastest possible edit/preview feedback loop possible

olafurpg avatar Oct 10 '21 06:10 olafurpg

Ah ha! Yes --include appears to do the trick!

Might be worth a note in the docs under the "process-single-markdown-file" section?

I hadn't bothered with --watch because to tell you the truth, processing a single file (with --in or --include) both throw an exception, so I foolishly assumed that --watch wouldn't work anyway... but funnily enough I've just tried it and I don't get the exception when using watch! Weird. Here's the message if you're interested (that's all of it):

Exception: sbt.TrapExitSecurityException thrown from the UncaughtExceptionHandler in thread "run-main-4"

Thanks again!

davesmith00000 avatar Oct 10 '21 20:10 davesmith00000