Hi all,
I noticed a glitch of PlDoc with modules that reexports the predicates of another module with the reexport directive.
When showing the PlDoc page of the original module, the reexported predicates, even if correctly documented in the other module, are shown as undocumented.
See e.g. the PlDoc of mcintyre from the cplint pack https://www.swi-prolog.org/pack/file_details/cplint/prolog/mcintyre.pl
that reexports cplint_util https://www.swi-prolog.org/pack/file_details/cplint/prolog/cplint_util.pl
Why can’t PlDoc retrieve the documentation from the reexported module?
Hi,
I noticed a difference between doc_save/2 and doc_server/2 on how they render files: the latter seems able to document more predicates for the same source file.
For example, in cplint when I create the html for the various modules with (file gen_docs.pl in subfolder docs)
reexported predicates get documented. Moreover, for module cplint_util, many predicates are not documented with doc_save/2, while they are with doc_server/2.
In turns out doc_save/2 processes an undocumented option include_reexported(Bool), which defaults to false. Adding this option as true indeed includes re-exported predicates. Possibly the default should change? Not sure, as it may duplicate the documentation. A module that merely combines functionality from other modules could have a header documentation that points at this while just linking to the documentation rather than duplicating it.
I agree, but currently if reexported predicates are not included, they appear as undocumented, which is ugly. I guess the best solution is what you propose, add a link to point to the documentation of the reexported module, maybe with a list of the reexported predicates (just name and parity).
However, there are problems also for modules that do not use reexport.
For example, for module cplint_util, I get the correct result only if I move the directory where the file is and from there I load the file and call doc_save(.,[]),
If I run it from folder docs, I get an access error while the folder is writable for me:
ERROR: /Users/fabrizio/.local/share/swi-prolog/pack/cplint/docs/gen_pldoc.pl:10:
ERROR: open/4: No permission to open source_sink `'/index.html'' (Read-only file system)
Warning: /Users/fabrizio/.local/share/swi-prolog/pack/cplint/docs/gen_pldoc.pl:10:
Warning: Goal (directive) failed: user:doc_save('../prolog/',[doc_root('./pldoc'),include_reexported(true)])
I had to make pldoc writable also by group and others.
If I use
Other observations: doc_save(.,[]) with modules with reexported predicates, lists, under the header
" Re-exported predicates", all the reexported predicates and lists all the exported predicates as undocumented.
If I use doc_save(.,[include_reexported(true)]) does the same, without the header.
If I use
I cloned your current cplint and looked at gen_pldoc.pl. If I generalize this code a bit, all seems to work fine. Probably vital is to load library(pldoc) first, such that all documentation is properly processed while loading the sources. The index_file(File) is not needed for a single file. It determines the file name when documenting a directory.
Also pushed some cleanup for PlDoc, but probably none of this is really relevant. Mostly use more the file file handling libraries to simplify the code and make it more robust.
P.s. cplint does not load in the current git version. library(clpr) can no longer be loaded as library(clp/clpr). This was never needed as the clp subdir of the library was in the library search path.