lukaslueg / macro_railroad_ext

Display syntax-diagrams for Rust-macros on docs.rs and doc.rust-lang.org
MIT License
185 stars 10 forks source link

Make work with local docs? #4

Closed dvdplm closed 4 years ago

dvdplm commented 5 years ago

Currently it seems like the browser ext only works for docs.rs and doc.rust-lang.org – what about a local doc build?

lukaslueg commented 5 years ago

There are two reasons:

As we currently only execute on rustdoc-generated pages anyway, the only filter is

https://github.com/lukaslueg/macro_railroad_ext/blob/b5e6ac771ff37d1d845c6967d5154f5c29b872de/extension/content_scripts/main.js#L12

We may get away with detecting generator = rustdoc in <head> but I'm not sure about this. If you are talking about "local docs", we might as well just request permissions for file://*-locations. This would not help with local networks, though.

dvdplm commented 5 years ago

Hmm, I understand the problem. No real elegant solution available I guess.

Sounds like the best solution would be to integrate this into rustdoc itself.

lukaslueg commented 5 years ago

If by "local" you mean "on disk" one should easily make it work by adding permissions to "file://".

WaffleLapkin commented 4 years ago

Is it possible to add a setting to the plugin, so users could at least say that "there is a macro on this page" or "this dir is a cargo project, so in sub-directories, there is documentation generated by cargo doc"? It would simplify debugging/writing macros a lot...

lukaslueg commented 4 years ago

I'll bump the extension's version due to bumped dependencies. There seems to be demand for using it on local/network files, which can only be done with *-permissions, which I'll add.

lukaslueg commented 4 years ago

I've rewritten all the Javascript-parts in Rust and updated the permissions. Anyone up for a local test before I bump the version on those browsers' webstores?

lukaslueg commented 4 years ago

Having thought about it some more, I'm inclined to revert 6bed4ec and just go with file:// alongside docs.rs and doc.rust-lang.org. This would exclude local networks but saves from asking for blank permissions. Since @WaffleLapkin and @dvdplm brought this up: Any comment?

WaffleLapkin commented 4 years ago

There are some docs not on docs.rs and doc.rust-lang.org, but they are rare, so file:// permission would be enough in 99% cases.

I couldn't build the extension locally to test it, though.

lukaslueg commented 4 years ago

The three browsers have been bumped in their respective webstores, it may take a couple of days for updates to pass review.

WaffleLapkin commented 4 years ago

It works, yay! 🎉🎉🎉

image

However, note that in chromium you need to also turn on "Allow access to file URLs":

image

lukaslueg commented 4 years ago

Noted in the README.

If you like, you can give the extension a vote in the webstore to promote it does not do anything devious :-)