Is there a utility that maps the include:: "genealogy" of a given file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Is there a utility that maps the include:: "genealogy" of a given file

My team and I use asciidoc includes to transclude content files into multiple assemblies, chapters, and/or guides.

Currently, we use a comment in the content file to manually record the "parent" files (called an assembly file) that include the content file as well as the names of the top level guides in which it appears (e.g., Getting Started Guide, Administration Guide).

Unfortunately, we sometimes forget to update this information.

Does anyone know of a utility or script (in bash, python, or any other language) that maps the genealogy of a "child" file on up through its "parents" (files that contain include::childname) up to the top level?  

In my imagination, this utility:
- uses a project folder as the starting point (docs-Red_Hat_Enterprise_Virtualization)
- takes a filepath and filename as an argument
- greps the project folder for that filename
- identifies the parent/ancestor files
- excludes false parents (i.e., excludes parents of files in different directory that have the identical filename)
- outputs the ancestry to a human-readable file.

The output might look something like this:

filename-of-guide-A > filename-of-chapter-A > filename-of-assembly > filename
filename-of-guide-B > filename-of-chapter-A > filename-of-assembly > filename
filename-of-guide-B > filename-of-chapter-B > filename-of-assembly-A > filename
filename-of-guide-B > filename-of-chapter-B > filename-of-assembly-B > filename

I'm hoping this already exists. I'd welcome any thoughts or suggestions.