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

feat: now supports minheaders flag #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benjamincharity
Copy link

@benjamincharity benjamincharity commented Mar 2, 2018

doctoc —minheaders X . will only generate a TOC if at least X headings exist

NOTE: Functionally this is complete; but I have not yet added tests. I am not very familiar with this testing format and one test already seems to be failing (prior to my change). Any help/direction here would be appreciated! 🙏

Closes: #141

Copy link
Collaborator

@PeterDaveHello PeterDaveHello left a comment

Choose a reason for hiding this comment

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

Is it possible that we can get some help from the latest LLM models to add some tests for it?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 suggestion.

Comments skipped due to low confidence (2)

lib/transform.js:117

  • [nitpick] The variable name minHeadersLevelHtml is inconsistent with the parameter name minHeadersLevel. It should be renamed to minHeadersLevel.
var minHeadersLevelHtml = minHeadersLevel || 0;

lib/transform.js:138

  • [nitpick] The variable name minHeadersLevelHtml is inconsistent with the parameter name minHeadersLevel. It should be renamed to minHeadersLevel.
var lessHeadersThanMin = linkedHeaders.length < minHeadersLevelHtml;

@@ -98,6 +98,9 @@ var stdOut = argv.s || argv.stdout
var maxHeaderLevel = argv.m || argv.maxlevel;
if (maxHeaderLevel && isNaN(maxHeaderLevel) || maxHeaderLevel < 0) { console.error('Max. heading level specified is not a positive number: ' + maxHeaderLevel), printUsageAndExit(true); }

var minHeadersLevel = argv.m || argv.minheaders;
Copy link
Preview

Copilot AI Nov 20, 2024

Choose a reason for hiding this comment

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

The variable 'minHeadersLevel' is assigned using 'argv.m', which is already used for 'maxHeaderLevel'. This could lead to unexpected behavior. Consider using a different variable for 'minHeadersLevel'.

Suggested change
var minHeadersLevel = argv.m || argv.minheaders;
var minHeadersLevel = argv.n || argv.minheaders;

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

Feature Request: Only generate ToC if at least X headings are found
2 participants