Commit Graph

462 Commits

Author SHA1 Message Date
Franco Masotti 81ce2a56d4
Added docstrings. 2021-01-19 17:36:54 +01:00
Franco Masotti 6eb9294d87
Added constant ordered list option. 2021-01-19 17:10:23 +01:00
Franco Masotti 27944ee5e1
Added comment. 2021-01-19 16:43:56 +01:00
Franco Masotti 89bf86b03b
Checked redcarpet links with git diff. Added a new section on ordered lists. 2021-01-19 13:24:46 +01:00
Franco Masotti 9afe10fc53
Added warning option. 2021-01-08 15:02:06 +01:00
Franco Masotti cf08b1b4c5
Fixed Makefile and pre-commit hooks. 2021-01-08 12:30:11 +01:00
Franco Masotti b42893cfb4
Removed whitespace. 2020-12-19 15:53:19 +01:00
Franco Masotti ab789a8315
Added a couple of links in the readme. Fixed an option. 2020-12-19 15:52:13 +01:00
Franco Masotti ed73949e9d
Preparing for new release. 2020-12-17 17:31:09 +01:00
Franco Masotti 562efa0c7a
Added asciinema files. 2020-12-17 17:26:59 +01:00
Franco Masotti 7ca07b011a
Added unit tests hook. 2020-12-17 13:59:48 +01:00
Franco Masotti a0fff389c8
Fixed issue #18. Cleanup. 2020-12-17 13:37:44 +01:00
Franco Masotti a573cc5d81
Added pre-commit example. 2020-12-10 18:07:44 +01:00
Franco Masotti a0c4ae6433
Fixed unit tests in PKGBUILD. 2020-12-10 14:57:32 +01:00
Franco Masotti c5f7341582
Fixed URL. 2020-12-09 19:36:48 +01:00
Franco Masotti 43d2461a91
Preparing for new release. 2020-12-09 19:31:54 +01:00
Franco Masotti e73bd395a5
Added asciinema files. 2020-12-09 19:21:51 +01:00
Franco Masotti 1de79f01c2
Fixed URLs. 2020-12-09 19:16:41 +01:00
Franco Masotti 7ffed17f46
Removed benchmark command. 2020-12-09 19:13:37 +01:00
Franco Masotti 41f3bcb09a
Removed benchmarks. Fixed tests module. 2020-12-09 19:12:32 +01:00
Franco Masotti 46cd921906
Updated dependencies. Removed test command from because of a deprecation warning. 2020-12-09 18:06:16 +01:00
Franco Masotti 32f61e749a
Fixed makefile, dependencies, documentation and pre-comit hooks. 2020-10-18 15:44:01 +02:00
Franco Masotti 760af5d5cc
Fixed spaces. 2020-07-13 11:15:03 +02:00
Franco Masotti f54917ffc7
Fixed documentation. 2020-07-01 11:13:07 +02:00
Franco Masotti 88ca2125b7
Imported PKGBUILD file from the AUR. 2020-06-26 12:51:46 +02:00
Franco Masotti 5c32bdb7d1
Updated packages. fpyutils modules are now called explicitly. 2020-06-24 11:26:49 +02:00
Franco Masotti b5b9f71b2a
Added asciinema files. 2020-06-24 10:44:43 +02:00
Franco Masotti 8db90dc93d Preparing for new release. 2020-05-20 11:52:55 +02:00
Franco Masotti 7ddf2b8fbd Updated asciinema files. 2020-05-20 11:46:39 +02:00
Franco Masotti 1b7f98a361 Fixed wording. 2020-05-20 11:34:26 +02:00
Franco Masotti a7d97dfcc8 Documentation fixes. 2020-05-19 19:55:42 +02:00
Franco Masotti 8a8a9b96dc Imported fixes from fpyutils. 2020-05-19 19:19:12 +02:00
Franco Masotti 1b96db3db2
Merge pull request #22 from jumanjiman/pre-commit-hook
Provide md-toc plugin for pre-commit framework
2020-05-19 19:13:04 +02:00
Paul Morgan 5b7a405570 Provide md-toc plugin for pre-commit framework
If a person uses to configure tests
for their git repos, they can now use md-toc as a plugin.

This commit:

- Adds `.pre-commit-hooks.yaml` to define the hook.
  It is a simple definition because md-toc ``
  is well-defined and provides a default entrypoint.

- Updates `README.rst` to provide end-user instructions.

I was hesitant to add a test to the Makefile.
However, it is easy to test via:

    # all markdown files
    pre-commit try-repo . md-toc --all-files

    # or a specific file
    pre-commit try-repo . md-toc --file

If all `*.md` files that have the TOC marker are up-to-date,
the output looks like:

    Update markdown table-of-contents........................................Passed

If any `*.md` files that have the TOC marker are updated by the plugin,
pre-commit fails the run and warns that it modified 1 or more files:

    Update markdown table-of-contents........................................Failed
    - hook id: md-toc
    - files were modified by this hook

Pre-commit automatically fails if any file is modified, which
forces the user to add the updated file to the commit.

💡 If you merge this, it would help users if you bump the
minor tag. Pre-commit users usually put a `rev: <tag>` in their
`.pre-commit-config.yaml`. They _can_ put a git hash or
`rev: latest`, but a tag is much more common.

If you merge this, I am happy to then submit a PR to pre-commit to
have it included in the index at
2020-04-05 01:23:10 +00:00
Franco Masotti ecd613047f Fixed asciinema link. 2020-03-26 23:08:28 +01:00
Franco Masotti 2797e2277d Preparing for new release. 2020-03-26 22:26:08 +01:00
Franco Masotti 0581b90202 Added note. 2020-03-25 18:13:10 +01:00
Franco Masotti de0af9728b Added new demo files. 2020-03-25 18:05:28 +01:00
Franco Masotti bd6bd6c210 Added donation button. 2020-03-25 16:17:35 +01:00
Franco Masotti 4c65955e1b Updated dependencies. 2020-03-25 16:01:49 +01:00
Franco Masotti c58ecca01c Added a method that adds an argument to the CLI parser. 2020-03-25 15:48:42 +01:00
Franco Masotti 1d35c65b36 Fixed makefile target and added symbolic links to make it working. 2020-03-24 12:36:20 +01:00
Franco Masotti 1d2dd01af8
Merge pull request #21 from jumanjiman/newfeature-reorder_positional_arguments
reorder positional arguments in CLI for easier automation
2020-03-24 12:14:17 +01:00
Paul Morgan b65cf32315 reorder positional arguments in CLI for easier automation
Before this commit

The demo script `asciinema/`
fails with multiple errors similar to this snippet of output:

    # one of multiple errors from output of demo script
    $ md_toc github
    usage: md_toc [-h] [-c | -i] [-l] [-m TOC_MARKER] [-p] [-s SKIP_LINES] [-v]
                  [FILE_NAME [FILE_NAME ...]] {github,cmark,gitlab,commonmarker,redcarpet} ...
                  md_toc: error: argument parser: invalid choice: '' (choose from 'github', 'cmark', 'gitlab', 'commonmarker', 'redcarpet')

`md_toc` requires the markdown parser to be the last positional argument
on the CLI. Filenames must be listed before the markdown parser.

    md_toc github

After this commit

The demo script works.

Reorder the positional arguments so filenames come last.

    md_toc github

⚠️ 3rd-party automation scripts, if any, require update
for order of positional arguments.

Arguably, this is an improvement. The implementation of markdown
parser as a subcommand means most people expect the markdown parser
to be the first positional argument. The arbitrary number of other
positional arguments typically come after the mandatory subcommand.

There are several ways to achieve the desired use case, but
this appears to be the smallest diff to do so.

Use case

Generically, this commit allows `md_toc` to be used in automation
scripts that pass an unknown number of filenames to the CLI.

My specific goal is to create a hook for
that can be configured in yaml like:

    - repo:
      rev: latest
          - id: md-toc
            args: [--skip-lines, 1, --in-place, gitlab]
            types: [markdown]

From the above yaml, uses to find all markdown files in a
changeset and execute a command with filenames as last arguments:

    md_toc --skip-lines 1 --in-place gitlab [all filenames]

The significant part of this construction is that
**filenames _must be_ the last positional arguments in the command**.
2020-03-22 20:17:00 +00:00
Franco Masotti c3cf551503 Preparing for new release. 2020-01-12 00:01:47 +01:00
Franco Masotti 1834887f07 Changed documentation theme. Minor fixes. 2020-01-11 23:57:45 +01:00
Franco Masotti ef555d098b Fixed issue 17: the list_marker variable is overridden in the build_toc function in case of calls similar to: "md_toc.build_toc(, ordered=True)". Added warnings in the documentation concerning issue 17. Ignore E129 for yapf, see: Updated Pipfile dependency. 2020-01-11 23:17:53 +01:00
Franco Masotti c9b757d16a Fixed .PHONY makefile target. 2020-01-11 13:36:11 +01:00
Franco Masotti 6267be971e Updated makefile and documentation. 2020-01-08 21:00:49 +01:00
Franco Masotti 4d48f5551f Updated copyright years. 2020-01-08 20:20:09 +01:00