[petsc-dev] Still unable to provide link from manual page into users manual after Sphinx

Barry Smith bsmith at petsc.dev
Sun Aug 28 12:40:30 CDT 2022



> On Aug 28, 2022, at 8:10 AM, Lawrence Mitchell <wence at gmx.li> wrote:
> 
> On Thu, 25 Aug 2022 at 13:37, Barry Smith <bsmith at petsc.dev> wrote:
>> 
>> 
>>  That would be great, thanks. Perhaps I am just not passing the label in the correct format in the .md file, I tried everything I could think of (and everything google suggested), and it either a) left my text untouched, meaning it didn't realize what I was providing was supposed to be a label or b) it complained that the label I provided did not exist.
> 
> So I've had a go and can make the following work:

  Thanks for checking on this. I am a bit confused.

> 
> If I edit one of the manual pages (e.g.
> doc/_build_classic/docs/manualpages/Mat/MATAIJCRL.md):
> 
> This works for me to create a link to the explicitly labelled section
> in the main manpages
> 
> [creating matrices](sec_matcreate)

What do you mean by "to the explicitly labeled section in the main manpages"? 

Do you mean if one has an "explicitly labeled section" in the users manual like 

.. _sec_matcreate:

Then I can use [creating matrices](sec_matcreate) inside a manual page and it does things properly? (I thought I tried this and it did not work, I'll try again).

Does the "explicitly labeled section" have to be only in the users manual or can it be anywhere on the Sphinx website? 

> 
> To link to a page in the docs you can use
> 
> [](/docs/manual/mat) (This uses the heading of the linked to page)
> 
> Or
> 
> [see also matrices](/docs/manual/mat)
> 
> Critical is to provide an absolute path from the root (or else a
> relative path [matrices](../../manual/mat))

Can this be anywhere in the website or just in the docs directory? How come there is / in front of the docs in [](/docs/manual/mat) ? Does that / mean the root?

> 
> Of course, something you would think should be possible is to link to
> the anchors that sphinx creates for every heading on every page, but
> this appears to be impossible. The anchors are generated by the
> backend unless you set some magic configuration option, and if you set
> that, I can't convince sphinx to link from the manpages to an anchor
> anyway.
> 
> If you want to have relative links to the generated docs from the
> markdown pages then set myst_all_links_external = True in conf.py and
> then the link target will be pasted in literally so
> [name](../../foo.html) turns into <a href="../../foo.html">name</a>.
> If you do this, then the magic link searching doesn't work.
> 
> Lawrence
> 
>>> On Aug 25, 2022, at 5:56 AM, Lawrence Mitchell <wence at gmx.li> wrote:
>>> 
>>> Hi Barry,
>>> 
>>> On Sun, 21 Aug 2022 at 20:56, Barry Smith <bsmith at petsc.dev> wrote:
>>>> 
>>>> 
>>>> To me, one of the best arguments to move to Sphinx was so that manual pages could have links directly into locations in the Users manual. Not possible in practice with a .pdf users manual.
>>>> 
>>>> With the manual in .rst and manual pages generated into .md this still appear to be impossible.
>>>>   1) when Sphinx is processing .md pages it appears to not know about labels defined in .rst files so  [matrix layout](sec_mat_something) doesn't work
>>>>   2) Raw, cruder things like [matrix layout](../../manual/mat.html#matrix-and-vector-layouts-and-storage-locations) don't work because it doesn't realize what is inside is a raw URL. I am guessing it needs the http:// at the beginning to realize it is a HTPP url and not a markdown thing.
>>>>   3) [matrix layout](https://petsc.org/main/docs/manual/mat/#matrix-and-vector-layouts-and-storage-locations) works
>>>> 
>>>> but hardwiring it this way is horrible. Could be release, could be (would be most of the time) a strange URL when running inside the CI. Is there a way to start with https::// but be a relative link?
>>>> figuring the anchor that Sphinx creates from a label (#matrix-and-vector-layouts-and-storage-locations) is super cumbersome.
>>>> 
>>> 
>>> I am pretty sure something close to your option (1) _should_ work, I
>>> will have a go at the weekend to see if I can figure things out. I
>>> agree that any of the others are less good.
>>> 
>>>> Is the only good solution to somehow generate .rst files with sowing? How come that wasn't done initially and instead .md files were generated? It seems insanely bad to have this mixture of .md and .rst for a website.
>>> 
>>> This should not be necessary: rst and markdown are both frontend
>>> formats to the parsed restructured text IR that sphinx uses (the
>>> markdown version goes through one additional conversion step
>>> internally, but that should not affect things here).
>>> 
>>> Lawrence
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220828/d0255b97/attachment.html>


More information about the petsc-dev mailing list