-
Notifications
You must be signed in to change notification settings - Fork 237
[Hi Haddock] In what format to export Haddocks in .hi files? #805
Description
An important design question of the Hi Haddock project is the choice of format that GHC shall use to include documentation in its .hi
interface files. I am currently aware of two competing proposals for that format:
-
Export the fully parsed and renamed AST in
haddock-library
's MetaDoc/DocH format. This is what I proposed in my GSoC proposal. I'll call this the DocH-variant. -
Export the raw docstrings, and all information that is necessary to rename identifiers in the documentation or to link to dependencies. Let's call this the raw-docstring-variant.
Here are some aspects of the two variants as I currently see them. Please mention any other aspects in the comments as I'm sure I've missed a few!
Aspects of the DocH-variant
- GHC will depend on
haddock-library
to parse the documentation. haddock
,ghci
and other consumers of the format don't need to do any further parsing or renaming.- Unlinkable identifiers are identified and warned about at compile-time.
Aspects of the raw-docstring-variant
- GHC gets a simple lexer that detects identifiers and links and determines what renaming information needs to be included in the interface files.
- The lexer may falsely detect some non-identifiers but that should at worst result in some bloat in the interface files.
- Tools that want to use a different syntax for documentation such as MarkDown or reStructuredText will only have to extend the lexer to detect identifiers in the new syntax.
- This in consequence makes it more likely that we will see other documentation formats and tools in the near future.
- This variant requires less work at compile-time, and is more likely to be cheap enough that the documentation can be output by default.
haddock
,ghci
etc. will have to rely onhaddock-library
or other documentation tools to parse and rename the docs.
(I don't think I'm misrepresenting this idea, but just in case, here is @gbaz's own description.)
Can both variants be combined?
I haven't thought about it much or discussed it, but it currently seems to me, that if I implement the DocH-variant as originally planned, it might not be too hard to add a code path for the the raw-docstring-variant which could be enabled via a ghc haddock-option.
Anyone who has a clearer idea of the things involved here: Please warn me, if you think I'm underestimating the complexity! :)