-
Notifications
You must be signed in to change notification settings - Fork 100
Allow reference to polymorphic variants when possible #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type switch = [ `On | `Off ] | ||
|
||
(** | ||
|
||
References with type as parent works: | ||
- {!type-switch.On} | ||
- {!type-switch.`Off} | ||
- {!type-switch.constructor-On} | ||
- {!type-switch.constructor-`Off} | ||
- {!switch.On} | ||
- {!switch.`Off} | ||
- {!switch.constructor-On} | ||
- {!switch.constructor-`Off} | ||
|
||
References in the environment don't work: | ||
- {!On} | ||
- {!`On} | ||
- {!constructor-On} | ||
- {!constructor-`On} *) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
$ ocamlc -bin-annot main.ml | ||
$ odoc compile main.cmt | ||
$ odoc link main.odoc | ||
File "main.ml", line 19, characters 5-23: | ||
Warning: Failed to resolve reference unresolvedroot(`On) Couldn't find "`On" | ||
File "main.ml", line 18, characters 5-22: | ||
Warning: Failed to resolve reference unresolvedroot(On) Couldn't find "On" | ||
File "main.ml", line 17, characters 5-11: | ||
Warning: Failed to resolve reference unresolvedroot(`On) Couldn't find "`On" | ||
File "main.ml", line 16, characters 5-10: | ||
Warning: Failed to resolve reference unresolvedroot(On) Couldn't find "On" | ||
|
||
$ odoc html-generate -o html --indent main.odocl | ||
$ cat html/Main/index.html | grep "<li>" -A 3 | ||
<ul><li><a href="#type-switch.On"><code>switch.`On</code></a></li> | ||
<li><a href="#type-switch.Off"><code>switch.`Off</code></a></li> | ||
<li><a href="#type-switch.On"><code>switch.`On</code></a></li> | ||
<li><a href="#type-switch.Off"><code>switch.`Off</code></a></li> | ||
<li><a href="#type-switch.On"><code>switch.`On</code></a></li> | ||
<li><a href="#type-switch.Off"><code>switch.`Off</code></a></li> | ||
<li><a href="#type-switch.On"><code>switch.`On</code></a></li> | ||
<li><a href="#type-switch.Off"><code>switch.`Off</code></a></li> | ||
</ul><p>References in the environment don't work:</p> | ||
<ul><li><code>On</code></li><li><code>`On</code></li> | ||
<li><code>On</code></li><li><code>`On</code></li> | ||
</ul> | ||
</div> | ||
</body> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Polymorphic constructors do not have an ID. When turning a resolved polymorphic constructor reference to an ID, a normal constructor ID is used.
But then, we need to ensure that this id, when turned to an href with anchor, does correspond link to the right place (that is, the page exists (which is always the case but also the html anchor exists).
Anchors are generated in
Url.Anchor.polymorphic_variant
, more precisely here. This function just tries to "force" the target anchor in IDs for constructor and the anchor for polymorphic constructor to correspond. I can remove it and replace it by a more detailed comment.I can also add IDs to polymorphic constructors that can be referenced, that means changes to
Lang
but maybe it is worth it.