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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

rolfedh
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.

Rolfe
Reply | Threaded
Open this post in threaded view
|

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

Alexander Schwartz
From your question I guess that you add the comments so that a human knowns where the file is used.

The AsciiDoc plugin for IntelliJ can give you this using "Find Usages" (Ctrl+F7) if you apply it to the file (not for example to a class name or something similar) and it will show you all include directives that point to this file

If you want to use this information for something else, please comment.

Alexander Schwartz (alexander.schwartz@gmx.net)
https://www.ahus1.de
Reply | Threaded
Open this post in threaded view
|

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

rolfedh
Thank you, Alexander. That's exactly the type of information we are looking for, but outside an IDE. Ideally, it would be available as a command-line utility.