Gnathtml.pl replacement

Did anyone try to replace gnahtml.pl with something else, possibly based on libadalang?
gnahtml.pl is a Perl script from AdaCore that produces a set of Web pages from Ada sources, by scanning the .ali files produced by the GNAT compilation.
It works fine but is a bit difficult to customize. Also it is based on deprecated HTML frames (although browsers support them).

Yes, there is:
https://docs.adacore.com/live/wave/gnatdoc4/html/gnatdoc-doc/introduction.html

Lovely!
Strange, the bodies’ sources are not shown under “Source Files”, despite the -b, -d and -p options.
Is there a way to make them appear?
Actually I am looking for a simple source browser - basically like what is generated by gnathtml but with “modern”-looking HTML frames.

My copy of gnatdoc=25.0.0 doesn’t have -b, -d, -p options. The (next-generation) documentation suggests you should use --generate=body. But when I try gnatdoc it fails with

raised ADA.IO_EXCEPTIONS.NAME_ERROR : Could not open gnatdoc/share/gnatdoc/html/template/index.xhtml

in spite of there being such a file in ~/.alire/share/gnatdoc/html/template/index.xhtml.

Interesting… The 23 (Pro) version shows, among others:

 -b                           Process bodies to complete the spec documentation
 -d                           Document bodies
 -p                           Process private part of packages

Perhaps some options were lost on the road?..

Anyway, the old Perl script (gnathtml.pl), reads the .ali files produced by GNAT on compilation and works fine.
Ideally an Ada-Perl bilingual could translate it to Ada. It would be easy to update and customize it then.

I originally implemented gnathtml (in 1998 !). Parsing ALI files is simple, but this is actually way more complicated than it looks. Since I first developed the tool, xref in ALI were added for generics, instances, parent types of tagged types,… resulting in quite a complex system of annotations.
I have tried since then to do something similar (in python) to find unused entities in our codebase, but this is at best inaccurate. Maybe I just did not spend enough time on it, but at this point it seems to me that ALI-based is not the way to go if you want an accurate tool

Following up on private messages: for those interested in understanding the ALI xref format, this is documented in lib-xref.ads if the GNAT sources

1 Like

Here is the very beginning of such a tool:

Actually the parsing is quite easy (if you skip some details :wink: ).