Add or update table of contents in specified file. Return 1 if file changed, 0 otherwise.
(input_file, min_toc_len, verbose=False)
| 359 | return headingExcludeRelease if isReleaseNotes(f) else headingExcludeDefault |
| 360 | |
| 361 | def updateSingleDocumentToC(input_file, min_toc_len, verbose=False): |
| 362 | """Add or update table of contents in specified file. Return 1 if file changed, 0 otherwise.""" |
| 363 | if verbose : |
| 364 | print( 'file: {}'.format(input_file)) |
| 365 | |
| 366 | output_file = input_file + '.tmp' |
| 367 | |
| 368 | markdownToclify( |
| 369 | input_file=input_file, |
| 370 | output_file=output_file, |
| 371 | min_toc_len=min_toc_len, |
| 372 | github=True, |
| 373 | back_to_top=False, |
| 374 | nolink=False, |
| 375 | no_toc_header=False, |
| 376 | spacer=False, |
| 377 | placeholder=False, |
| 378 | exclude_h=excludeHeadingsFor(input_file)) |
| 379 | |
| 380 | # prevent race-condition (Python 3.3): |
| 381 | if sys.version_info >= (3, 3): |
| 382 | os.replace(output_file, input_file) |
| 383 | else: |
| 384 | os.remove(input_file) |
| 385 | os.rename(output_file, input_file) |
| 386 | |
| 387 | return 1 |
| 388 | |
| 389 | def updateDocumentToC(paths, min_toc_len, verbose): |
| 390 | """Add or update table of contents to specified paths. Return number of changed files""" |
no test coverage detected