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

Add '--ordered option' to toc generation #34

Merged

Conversation

lbenezriravin
Copy link
Contributor

Functionally backwards compatible. Moves the regex crate from dev-dependencies into the main dependencies.

In many (probably most) cases, the Table of Contents generated will look like this:

* [1. foo](0001-foo.md)
* [2. bar](0002-bar.md)
* [3. baz](0003-baz.md)

In my opinion this is ugly markdown, since it generates an unordered list and adds unsyntactic ordering after the fact. When rendered, it will look a lot like an ordered list, but with useless bullets in front of each item.

This patch adds a flag to leverage the common title structure generated by adrs to create a cleanly ordered list:

1. [foo](0001-foo.md)
1. [bar](0002-bar.md)
1. [baz](0003-baz.md)

Without the flag, output is unchanged. A few notes on error catching:

  • This feature is implemented against the commonmark standard, so only up to 9 digits are allowed in the identifier in the title. Please do not write a billion ADRs and attempt to generate a TOC with this flag.
  • While these cases will not come up if ADRs are generated with adrs, some allowances are made for custom setups:
    • Ordering is done entirely based on title contents. If the file has a conflicting number, or none at all, it will be disregarded. This allows for a slightly DRYer setup if desired.
    • Numbers cannot be missing, as commonmark has no allowances for out-of-order ordered lists.
    • All ADR titles must start with a valid ordered list identifier. This feature does not allow mixing and matching between styles.

Functionally backwards compatible. Moves the regex crate from
dev-dependencies into the main dependencies.

In many (probably most) cases, the Table of Contents generated will look
like this:

```
* [1. foo](0001-foo.md)
* [2. bar](0002-bar.md)
* [3. baz](0003-baz.md)
```

In my opinion this is ugly markdown, since it generates an unordered list and
adds unsyntactic ordering after the fact. When rendered, it will look a
lot like an ordered list, but with useless bullets in front of each
item.

This patch adds a flag to leverage the common title structure
generated by adrs to create a cleanly ordered list:

```
1. [foo](0001-foo.md)
1. [bar](0002-bar.md)
1. [baz](0003-baz.md)
```

Without the flag, output is unchanged. A few notes on error catching:

* This feature is implemented against the commonmark standard, so only
  up to 9 digits are allowed in the identifier in the title. Please do
  not write a billion ADRs and attempt to generate a TOC with this flag.
* While these cases will not come up if ADRs are generated with adrs,
  some allowances are made for custom setups:
  * Ordering is done entirely based on title contents. If the file has a
    conflicting number, or none at all, it will be disregarded. This
    allows for a slightly DRYer setup if desired.
  * Numbers cannot be missing, as commonmark has no allowances for
    out-of-order ordered lists.
  * All ADR titles must start with a valid ordered list identifier. This
    feature does not allow mixing and matching between styles.
@lbenezriravin
Copy link
Contributor Author

Hi @joshrotenberg , thanks for maintaining this tool! I made a patch to fix a minor nit that I had with the output of most adr tools I've come across. Please let me know if this is a feature you're open to and/or if you have any suggestions for improvements.

@joshrotenberg
Copy link
Owner

Hi @joshrotenberg , thanks for maintaining this tool! I made a patch to fix a minor nit that I had with the output of most adr tools I've come across. Please let me know if this is a feature you're open to and/or if you have any suggestions for improvements.

Thanks for this! I'll take a closer look later today, but I'm definitely open to this (and other) new features if you have more ideas.

Copy link
Owner

@joshrotenberg joshrotenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the contribution!

@joshrotenberg joshrotenberg merged commit a4578ee into joshrotenberg:main Apr 22, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants