Skip to content
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

Annotate pretty-printed output with full constant names #89

Merged
merged 5 commits into from
Jan 27, 2020

Conversation

gebner
Copy link
Member

@gebner gebner commented Dec 17, 2019

Motivation: we want to have links for all constants in the API documentation, even if they are behind notation. See companion PR leanprover-community/doc-gen#3.

This PR adds the option pp.links which, if set to true, annotates things like and + and the fst in p.fst with the corresponding constant names (i.e., int, has_add.add, and prod.fst). The markup syntax for this annotation is as follows:

<U+E000>prod.fst<U+E001>fst<U+E002>

The Unicode code points U+E000, U+E001, U+E002 are taken from the Private Use Area. Hopefully nobody uses them for anything else.

@gebner
Copy link
Member Author

gebner commented Dec 17, 2019

I also added a pp.generalized_field_notation that uses field notation for all function instead of just structure projections.

@Vtec234
Copy link
Collaborator

Vtec234 commented Dec 17, 2019

Do you think with the full knowledge of type information, we could link to the correct instance of a typeclass rather than the typeclass itself? E.g. the in 1 • b = b could link to the inferred instance of has_scalar mytype rather than has_scalar.smul.

@gebner
Copy link
Member Author

gebner commented Dec 17, 2019

I would also like to see that. In practice I'm not sure there's an always an obvious choice for the instance declaration. E.g. in your example with , the instance for has_scalar is mul_action.to_has_scalar, which is probably not what you want.

@cipher1024
Copy link
Contributor

This looks good to me. I especially like what you did to pretty print projections. Ready to merge?

@gebner
Copy link
Member Author

gebner commented Dec 18, 2019

Yes, I think this can be merged. The pp.generalized_field_notation option is turned off by default though. Should we switch it on by default?

@robertylewis
Copy link
Member

For doc gen reasons, could I request that this PR be included in a 3.5 release before we officially move mathlib over to 3.5?

@cipher1024
Copy link
Contributor

Certainly. Sorry I completely lost sight of this PR. We can schedule 3.5.1 in the near future to make this PR available. Let's see if you have backward compatible PRs until then.

@robertylewis
Copy link
Member

@cipher1024 In advance of the shift to 3.5c, could we merge this so it's part of the nightlies?

@cipher1024 cipher1024 merged commit 71c2d38 into leanprover-community:master Jan 27, 2020
bors bot pushed a commit that referenced this pull request Nov 11, 2022
This uses `U+E003` (the next available private use character after the ones claimed in #89) to prefix the names:

* `pi`
* `forall`
* `function`
* `implies`
* `Sort`
* `Prop`
* `Type`

The motivation is to be able to link these ideas in doc-gen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants