MCPcopy Create free account
hub / github.com/catchorg/Catch2 / updateDocumentToCMain

Function updateDocumentToCMain

tools/scripts/updateDocumentToC.py:398–442  ·  view source on GitHub ↗

Add or update table of contents to specified paths.

()

Source from the content-addressed store, hash-verified

396 return n
397
398def updateDocumentToCMain():
399 """Add or update table of contents to specified paths."""
400
401 parser = argparse.ArgumentParser(
402 description='Add or update table of contents in markdown documents.',
403 epilog="""""",
404 formatter_class=argparse.RawTextHelpFormatter)
405
406 parser.add_argument(
407 'Input',
408 metavar='file',
409 type=str,
410 nargs=argparse.REMAINDER,
411 help='files to process, at default: docs/*.md')
412
413 parser.add_argument(
414 '-v', '--verbose',
415 action='store_true',
416 help='report the name of the file being processed')
417
418 parser.add_argument(
419 '--min-toc-entries',
420 dest='minTocEntries',
421 default=minTocEntries,
422 type=int,
423 metavar='N',
424 help='the minimum number of entries to create a table of contents for [{default}]'.format(default=minTocEntries))
425
426 parser.add_argument(
427 '--remove-toc',
428 action='store_const',
429 dest='minTocEntries',
430 const=99,
431 help='remove all tables of contents')
432
433 args = parser.parse_args()
434
435 paths = args.Input if args.Input else [documentsDefault]
436
437 changedFiles = updateDocumentToC(paths=paths, min_toc_len=args.minTocEntries, verbose=args.verbose)
438
439 if changedFiles > 0:
440 print( "Processed table of contents in " + str(changedFiles) + " file(s)" )
441 else:
442 print( "No table of contents added or updated" )
443
444if __name__ == '__main__':
445 updateDocumentToCMain()

Callers 1

Calls 2

updateDocumentToCFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected