Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

[WIP] Hi Haddock #906

Closed
wants to merge 143 commits into from
Closed

[WIP] Hi Haddock #906

wants to merge 143 commits into from

Conversation

sjakobi
Copy link
Member

@sjakobi sjakobi commented Aug 14, 2018

(GSoC project description)

What already works

For many packages we can already generate reasonably-looking haddocks. For example see these haddocks for lens.

TODOs

  • Get html-test to run. Currently we can't handle the Bug294 test-case. This requires changes in extractDecl. (Details) Fixed by @harpocrates in 29edbb9.

  • Scrutinize output changes and update the tests. In particular we currently generate kind signatures for all higher-kinded type variables. (Details)

  • Fix --hyperlinked-source by integrating Zubin Duggal's GSoC project.

  • Warnings for ambiguous identfiers are too noisy. (Details)

A few more smaller issues are marked TODO in the source code.


The corresponding changes in GHC are on Phabricator.

@sjakobi
Copy link
Member Author

sjakobi commented Oct 22, 2018

@harpocrates I've updated the Phab diff according to your instructions. Thanks a lot for the rebase!

I actually wouldn't mind if you'd comandeer the diff BTW.

@sjakobi
Copy link
Member Author

sjakobi commented Oct 26, 2018

@harpocrates Could you give cad2ed9 a quick review?

The main thing I'm worried about is that in hsDocRenamer, I might recreate the env for each identifier I'm looking up. I'm just not sure what kind of code GHC generates there… :/

hsDocRenamer :: HsDoc Name -> Renamer
hsDocRenamer hsDoc s =
let env = Map.mapKeysMonotonic unpackHDS (hsDocIdEnv hsDoc)
in Map.lookup s env

sjakobi added a commit to sjakobi/ghc that referenced this pull request Jan 5, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
sjakobi added a commit to sjakobi/ghc that referenced this pull request Jan 5, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
sjakobi added a commit to sjakobi/ghc that referenced this pull request Jan 5, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
sjakobi added a commit to sjakobi/ghc that referenced this pull request Jan 5, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
bgamari pushed a commit to ghc/ghc that referenced this pull request Jan 21, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

## Main changes

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

## TODOs and requests for comment

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.
      See [haddock#956](haskell/haddock#956).

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.
    Also discussed at [haddock#956](haskell/haddock#956).

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

* [ ] Serialize instance locations. Discussed at [haddock#921](haskell/haddock#921).

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

## Possible further work

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
sjakobi added a commit to sjakobi/ghc that referenced this pull request Jan 26, 2019
Summary:
This extends my work from D4758 and enables haddock to generate docs
from information enclosed in the `.hi` interface files.

* `HaddockLex` contains an Alex-based lexer for docstrings that detects
  identifiers delimited with `'` or backticks.

* `HsDoc.Docs` comprises the `DeclDocMap` and `ArcDocMap` structures added in D4758 and
  other data needed by haddock.

* haddock now uses `GhcMake.load'` to load `.hi`-files, hooking into GHC's recompilation
  avoidance. In order to avoid recompilation when a `.hi`-file already contains documentation
  we use a new option `Opt_SkipIfaceVersionCheck`.

* [ ] Work out a specification for a deterministic module structure (`docs_structure`) and
      update the existing code to implement it. The `HaddockIssue849` test case is currently flaky
      because the ordering of constructors in the `Avail` for `Maybe` fluctuates.
      See [haddock#956](haskell/haddock#956).

* [ ] Possibly fuse `mi_exports` and `docs_structure`. Currently both serialize the same `Avails`.
    Also discussed at [haddock#956](haskell/haddock#956).

* [ ] Get the recompilation avoidance right: While some of the checks performed in `checkVersions`
      are irrelevant for haddock, we may want to keep some of them.
      We probably also want `-haddock` to cause recompilation if an existing `.hi`-file
      doesn't contain the `Docs`.

* [ ] Fix the tests. `./validate` currently reports failures for
      `TEST="HaddockIssue849 ImpSafeOnly01 ImpSafeOnly02 ImpSafeOnly03 ImpSafeOnly04 ImpSafeOnly05 ImpSafeOnly06 ImpSafeOnly07 ImpSafeOnly08 ImpSafeOnly09 ImpSafeOnly10 Splices T13168 T14304 T4029 T9881 break006 break011 break013 break024 cabal01 dynamicToo002 dynamicToo005 haddock.base haddock.compiler hist001 hist002 plugins09 plugins11 print026 safePkg01"`

* [ ] Serialize instance locations. Discussed at [haddock#921](haskell/haddock#921).

Several more (minor) issues are marked `TODO` in the source code.

---

The corresponding changes in haddock are [here](haskell/haddock#906).

* Add an option to configure the identifier delimiters the lexer looks for.
* Add an option to make the lexer exclude birdtracks.
* Make the `:doc` command also pretty-print arg docs.

Reviewers: bgamari, alanz, harpocrates, alexbiehl, hvr

Subscribers: Tritlo, Fuuzetsu, thomie, rwbarton, mpickering, carter, wz1000, harpocrates, gershomb, hvr, alexbiehl

GHC Trac Issues: #15786

Differential Revision: https://phabricator.haskell.org/D5067
@bgamari
Copy link
Collaborator

bgamari commented Sep 12, 2019

What is the status of this?

@sjakobi
Copy link
Member Author

sjakobi commented Sep 13, 2019

It's good that you're asking, @bgamari. !1648 reminded me of some pretty cool work by @harpocrates among the other Hi Haddock stuff that resulted in proper haddocks for [] and (->).

I had got stuck on #921 last winter, and had little time for this project. In March I ended up asking @harpocrates to take over the remaining work.

Back then I was under the impression that there were still quite a few tricky (tricky for me) issues to resolve. AFAIK the latest TODO list is this one. What made everything more difficult was the need to sync (and rebase) things between haddock and ghc.

I'm wondering whether there could be a way to merge parts of the work incrementally, reducing the amount of changes outside of master that have to be kept in sync.

@harpocrates what's your perspective on all this these days?

@harpocrates
Copy link
Collaborator

Sorry, I'm definitely at fault for dragging my feet on this. I thought I'd negotiated 2 weeks of paid time for this with my employer last April, but that ended up not panning out. Lately I have a bit more time - perhaps even as early as this month...

@Kleidukos
Copy link
Member

What is our current status? Is there a way to better split this PR?

@Kleidukos
Copy link
Member

@harpocrates @sjakobi

@Kleidukos
Copy link
Member

Hi! As of today, patches for the ghc-head branch must be done on the Haddock mirror on GitLab, at https://gitlab.haskell.org/ghc/haddock.

@Kleidukos Kleidukos closed this Dec 17, 2021
@Kleidukos Kleidukos deleted the wip/hi-haddock branch December 27, 2021 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants