Skip to content

Ensure that module-used-by comment in AsciiDoc files is accurate

License

Notifications You must be signed in to change notification settings

mikemckiernan/module-used-by

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

module-used-by

🔥

This repository is beta software.

The purpose of this pre-commit hook is narrow. The goal is to ensure that Asciidoc (.adoc) files in the modules directory of the openshift-docs repo are updated with the names of the assembly AsciiDoc files that reference them.

Installation

See pre-commit for instructions.

Sample .pre-commit-config.yaml:

repos:
  - repo: https://github.com/mikemckiernan/module-used-by
    rev: v0.1.4
    hooks:
    - id: module-used-by
      args: ["--ignore-dir=drupal", "--ignore-dir=rest_api", "--ignore-dir=contributing_to_docs", --ignore-file="README.adoc"]
      types: [asciidoc]

Refer to the tags page to find the most recent rev.

The args field is optional, but harmless to include with versions >= v0.1.4. You can specify additional directories for files to ignore from consideration.

Limitations

Other information in a module-used-by block comment

Comments at the end of the module-used-by block comment are not preserved. If the comment block ends like the following example, then the hook deletes last two lines of the comment.

Sample input for a comment block with trailing information
...
// * cookies/holiday/gingerbread.adoc
// * cookies/chocolate-chip.adoc
//
// Bread recipes link to this; do not change anchor
Sample output with the trailing information deleted
...
// * cookies/holiday/gingerbread.adoc
// * cookies/chocolate-chip.adoc

Comments before the module-used-by block comment

If the module-used-by block comment is preceded by another comment, the hook deletes the first comment and then inserts the module-used-by block comment. As a result, the hook leaves the file with the original module-used-by comment block as the second comment, or in any subsequent position.

Sample input for a preceding comment block
// TODO -  possibly delete this file
// Or does someone want anchovy-and-anise-flavored cookies?

// Module included in the following assemblies:
//
Sample output with the first comment block deleted
// Module included in the following assemblies:
//
// * installing/installing_aws/installing-aws-network-customizations.adoc
// * installing/installing_azure/installing-azure-network-customizations.adoc

// Module included in the following assemblies:
//
...

Contributing

Run the tests with the following command:

python -m pytest

About

Ensure that module-used-by comment in AsciiDoc files is accurate

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages