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 Request: Only generate ToC if at least X headings are found #141

Open
benjamincharity opened this issue Feb 22, 2018 · 2 comments · May be fixed by #142
Open

Feature Request: Only generate ToC if at least X headings are found #141

benjamincharity opened this issue Feb 22, 2018 · 2 comments · May be fixed by #142

Comments

@benjamincharity
Copy link

benjamincharity commented Feb 22, 2018

Use case

I want to update many README files throughout my project but I don't want to add a ToC to files with only a single section or heading.

# example flag
$ doctoc --minheaders 3

With the above command, this file would not get a ToC:

# Heading One

content

# Heading Two

content

While this file would get a ToC:

# Heading One

content

# Heading Two

content

# Heading Three

content
@thlorenz
Copy link
Owner

thlorenz commented Feb 25, 2018

Interesting idea, but should be --minHeaders 3 to omit the first case right .. since it does have 2 headers?
No bandwidth ATM, I put a help-wanted label.
You are very welcome to add this feature, I like the idea :)

Please submit a PR if you can

@benjamincharity
Copy link
Author

benjamincharity commented Mar 2, 2018

@thlorenz I have opened a PR that I believe is feature complete, but with no test for the new functionality: #142

I am a bit unfamiliar with the current testing setup so would very much appreciate any direction on how to test this as I'm sure you want test coverage prior to merging.

Specific testing issues are:

  • a) a test seems to be failing prior to my changes
    • # Subtest: transforming not ok 1 - anchors.split is not a function
  • b) I am unsure how to test that the TOC wasn't generated

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

Successfully merging a pull request may close this issue.

2 participants