-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
DOC: constants: Add constants.svg
tree
#11143
base: main
Are you sure you want to change the base?
Conversation
As you suspected @mkg33, a few fun CI failures. On TravisCI the refguide check fails with
You should be able to reproduce that locally with The doc build on CircleCI has a more informative warning for the same
This is because
I'm not sure it will, I doubt it actually. I can't remember we have tried directly linking from a docstring to a file outside the source tree. An alternative could be to add the |
Thanks, @rgommers. I got optimistic because this setup actually worked with |
|
Thanks for checking it, @rgommers. That's quite weird but I'll fix it. After trial and error, I managed to install/upgrade certain dependencies (to build the documentation locally) but now I'm getting this error and I've no idea how to fix it (no luck finding the answer on Google either):
Have you seen it before? Just to be clear: I'm trying to build it from the current cloned As for the SVG itself: I'm aware it inserts it 'whole' and not as an image. That was the only solution that worked. In the meantime, I improved the script for inserting links and took care of exception handling. |
That's not pretty. It's probably something in the build. You can try running |
scipy/constants/__init__.py
Outdated
@@ -7,6 +7,9 @@ | |||
|
|||
Physical and mathematical constants and units. | |||
|
|||
.. raw:: html |
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.
Here html
indicates the Sphinx "writer". So this will work (once the file is found) for the html docs, but not the pdf docs. @mkg33 I think you tried working with pdf output right? Can you remind me of the details?
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.
Thanks so much for trying to make sense of this mess. The thing about the PDF solution was this, quote from my e-mail:
So here's another solution: including the trees as pure PDFs. I've browsed the Net for similar solutions and it doesn't seem unreasonable (indeed, people have done this and apparently succeeded). Would this idea be acceptable? I have to admit, it would be great quality-wise and would facilitate maintenance. Another way would be exporting the tikzpictures as SVG - preserves the quality (though, again, not the font, but I can fix that) and is browser-friendly (in the mainstream sense).
And we later discussed the output format and you said that the SVG solution was better and that's what we'd agreed on initially. So, in a sense, I didn't even pursue the PDF solution any further. I wanted to choose PDF over SVG due to the links issue (recall that due to some unresolved bug, see the issue here, pdftocairo
doesn't preserve links in the output; and, yes, I've tried multiple PDF->SVG converters and they either distort the quality/font or remove the links).
Let's wait and see what others propose with regard to this issue. I'd be very happy to work on another solution.
This last commit should pass CI. It may not be the optimal solution. Note that it only works for html, not for latex/pdf (the Sphinx writers after Perhaps a custom Sphinx directive is needed here (EDIT: something along the lines of autoimage). @larsoner or @pv, any opinion on the best way to tackle this image inclusion issue? |
Also for reference, this is where the |
And for some more context: the issue is that |
@rgommers regarding the build:
I'm getting this now:
And here's the end of the thread listing:
To add more context to the choice of the
also fails to produce the output we want (there's just a blank square). The
directive ( Again, the above results refer to the |
Let's separate that problem from this PR. There's something in your setup, hard to guess what. Perhaps open a new issue, and we can try and debug it together over chat/call later this week. |
All CI failures are unrelated. Doc build works, but links don't work very smoothly - sometimes they do, sometimes they don't. The links within the SVG look differently than the other links on the page:
for SVG vs.
for Sphinx-generated links in the sidebar. Those |
@rgommers Alright, I'll move the setup issue. As for the links, that's unexpected because I tested it with the I just changed it to Could you test it? Here is the updated file: |
Visually this fits better now: Most links are still broken though. The ones that are links to a section on the same page work, links to other pages don't (the link format assumes everything is on that page). We'll need to find a better way to post-process the image to update the links. Each page does have the correct link in it somewhere, so that could be scraped. For example, for
while the correct link would be
|
I get it now. My prototype didn't take into account the exact nature of the links because I simply had no access to the local build. It doesn't seem too difficult (or else I'm very wrong): from what I've noticed in the page source, we just need to provide the I've modified the script so that the external pages are encoded differently (as You can review the updated solution here (lines 13-41). And here's another test file if you still have the patience to test it for me... |
This is crazy, it looks completely fine in browser preview. Anyway, a silly mistake - I've changed the script accordingly and also decided to hardcode the hash so that the user won't have to type it in every line. Here's the file. I've opened an issue regarding my problems with building the documentation. |
Yep, for me too - it's just messed up inside the Sphinx page. Looking at the source, all the links of the orange boxes are fine now. The purpose boxes however aren't. Example: |
Correct me if I'm wrong but shouldn't the link actually look like that? This is copied verbatim from the documentation source online:
I assume that the |
@rgommers could you perhaps try the most recent solution and see if it works on your computer? I'm still unable to set up my local build. I'm quite confident it is correct this time (I mean the hyperlinks etc.; cf. my last comment). I really want the trees to work :-) |
Testing whether the embedding of constants.svg works.
This may not be the optimal solution. Note that it only works for html, not for latex/pdf (the Sphinx writers after ``.. raw::`` are the only ones used). Perhaps a custom Sphinx directive is needed here.
Hi @mkg33, I hope you're doing okay! We finally have an online development environment integrated via Gitpod, see http://scipy.github.io/devdocs/dev/contributor/quickstart_gitpod.html#quickstart-gitpod. That made me think of this PR. I brought it up-to-date with current master (we also have a new Sphinx theme, it's pretty now!). Gitpod should avoid all the "building SciPy is very painful" problems, you get dropped into a VS Code environment where SciPy and the docs are already built (or being built on first start up). There's still things that need fixing, like the image width and the pdf build, but I hope this resolves the biggest blocker to work on this PR. |
Hi Ralf, it's great to hear from you! I've been thinking about this PR recently. I'm so glad that I can now try other solutions without having to deal with my local setup problems. I have 2 exams until May 15th but I'll definitely work on it afterwards. I'm really happy there's a chance to use the trees and merge this PR :-) ! |
constants.svg
tree
@mkg33 Hope your exams went well! Were you still interested in finishing up this PR? |
This is an example of a graphical guide embedded in the
API Constants
page. Basically, it is atikzpicture
converted toSVG
with links added by means of a simple script (see here for more details). There have been quite a few issues with linking the tree nodes with the respective parts of the API page. Since I'm unable to build the documentation locally (seriously), I've experimented extensively with a similar layout (scipy.org
) and I can confirm that theSVG
file renders correctly. I'd be really grateful for any comments / general feedback.