-
Notifications
You must be signed in to change notification settings - Fork 34
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
New role ghref for pointing to files on github #56
Conversation
The code looks good. Some high-level questions:
|
Thanks, I did update the code and implemented permalinks.
I'd like my tutorials to stay .v files, so I don't know ;-) I call alectryon... I'm pretty clueless on doc tools, I'm happy If I can stay ignorant on this matter ;-)
Sure, but I have no clue on how to make it persistent. Any pointers?
This looks like a very natural feature, I did google it but could not find it. I still see a few advantages in doing things this way:
What you propose makes a lot of sense for non-GH links, IMO. |
@cpitclaudel I'd like some hints on the cache thing, and any other comment on this PR, so that I can finish it. |
Yep, will get to it. It took me a while because I was working on the Pygments stuff first ^^ |
Just had a new look, the code looks reasonable (though an API that involves On the cache: Sphinx has decent support for caching natively; for a more general solution you could just open a file and update it every time you try to resolve one of these links. If that's too bad for performance (opening and writing a file for every such link), then you would use a transform: you'd delay most of the work of resolving links and then resolve all links at once (along with updating a cache) in a "Transform". Not sure if it's worth the effort. I'm expecting this code will evolve as the use-case gets refined, and I'm not entirely comfortable with running arbitrary code every time Alectryon compiles a document, so I'm not sure about merging this as-is. For your use case, if Alectryon had a --plugin flag that you could pass a Python file to, would it be enough? That's easy to add, and custom plugins are a pretty common use case (I originally thought people would use custom drivers built on top of Alectryon for things like that, but a |
Hum --plugin is fine, but I prefer to clean it up if it can be merged, eventually. You tell me. About eval, I think a replace expression is more than enough, I just don't know which is the best way to pass something like About the cache, I can write to a file. I was just wondering if alectryon already had a cache (invalidation) mechanism to hook to. |
I should have addressed all issues. The cache is still to be done. |
I'd prefer to keep this external for now, and if it catches on we can merge it. Let me know if that works for you.
Probably as an argument with that
There is, but it's only keeping track of the Coq parts, not of anything related to docutils. Sphinx has an extensible caching mechanism, but it doesn't work with plain Docutils. I think your best bet is a separate cache file. |
OK, thanks for you reviews by the way. I guess the --plugin will let me both register one extra role and monkey patch the pygment style, right? |
I changed that already into 2 options, the second one defaulting to the empty string which is what I currently need. |
7c226b6
to
fa3ed76
Compare
please have a look at the last commit to see what I mean |
OK, I've looked into nested parser. I pushed an example in I think that's the most flexible solution, since with a plugin there's always the risk that things get imported in the wrong order, whereas with a custom driver your code is guaranteed to run first. I think that's the right solution, but if after looking into the new documentation and example you think a --plugin flag would be much better I can add that, too. |
Thanks, I'll look at it more carefully, but after a quick look I still don't get how you go back to he host language from, say, CLexer. alectryon/recipes/custom_highlighting.v Line 54 in 95a31c4
|
As a reference, see the second code block here: https://lpcic.github.io/coq-elpi/tutorial_coq_elpi_HOAS.html#quotations-and-antiquotations |
Would it not work to mark the Gallina-inside-ELPI tokens as "other"? |
Now I recall what my problem was. In order to use
but this does not work for me since |
Thanks, you're right, and sorry for being a bit slow at this. I think your approach is likely to be the best there is. What you could do, for sure, is a three-step process: first use a simple lexer that tags each bit of code as Coq or ELPI, and then use two nested So your approach is good, I think. I will leave specific comments inline. |
Yup, just went through everything. I think your approach works nicely, and I can't think of something much smoother. |
Thanks for all the help, I could move to a custom driver: LPCIC/coq-elpi#283 |
Woohoo! Thanks so much for your patience and for helping me understand the issue(s) :) The new tutorials look great. |
I find myself adding links to stuff which is not a coqdoc generated html file, so I came up with this hack.
In my first rst comment I do:
and then I can easily put links to my (builtin or defined) APIs or data type declarations.
The pattern is used to locate the line (in the raw file) so that the href can point to
$file#L$line
, in turn GH highlights the line.Todo:
<a class="d-none js-permalink-shortcut" data-hotkey="y" href="/gares/alectryon/blob/f256fe49367d1cadbeeb4285e9786a3fc79f286a/CHANGES.rst">Permalink</a>
)src
, egorg
+repo
+path
Feedback is welcome.
Disclaimer: last time I wrote some python it was version 1 (yes, there were no objects) so my code is likely to suck.