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

Use sphinx.ext.extlinks to add Sphinx roles for links to external package docs #27495

Closed
dimpase opened this issue Mar 15, 2019 · 100 comments · Fixed by #37598
Closed

Use sphinx.ext.extlinks to add Sphinx roles for links to external package docs #27495

dimpase opened this issue Mar 15, 2019 · 100 comments · Fixed by #37598

Comments

@dimpase
Copy link
Member

dimpase commented Mar 15, 2019

We wish to link to external packages' documentation:

  • if the package documentation is installed locally in the Sage distribution, using the file link
  • in downstream packaging, using a file link appropriate for the doc installation scheme of the system (without having to patch the documentation)
  • if it is not available locally, using an http link to an online version of the package's documentation.

To this end, we use the sphinx.ext.extlinks facility, for which we already have infrastructure in sage.misc.sagedoc, assigning a Sphinx role to every external document.

We use a systematic naming scheme for these roles: :spkg_SPKG_DOC: where DOC is usually just doc but if a package has several manuals, it can be used to distinguish them.

In this ticket, we do this for the documents covered by a previous iteration of this ticket:

The location of some of the locally installed documentation files can be determined at runtime, see #27495 comment:58 for maxima.
This should probably go through sage.feature.

Related:

CC: @tobihan @kcrisman @kiwifb @embray @haraldschilly @mkoeppe @antonio-rojas @mwageringel @videlec

Component: documentation

Keywords: sd111

Issue created by migration from https://trac.sagemath.org/ticket/27495

@dimpase dimpase added this to the sage-8.8 milestone Mar 15, 2019
@dimpase
Copy link
Member Author

dimpase commented Mar 16, 2019

Branch: u/dimpase/doc/docrefs

@dimpase
Copy link
Member Author

dimpase commented Mar 16, 2019

Commit: f82a7c2

@dimpase

This comment has been minimized.

@dimpase
Copy link
Member Author

dimpase commented Mar 16, 2019

Author: Dima Pasechnik

@dimpase dimpase modified the milestones: sage-8.8, sage-8.7 Mar 16, 2019
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 16, 2019

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

13c2fd5trac 27495: links to external docs in reference index.rst

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 16, 2019

Changed commit from f82a7c2 to 13c2fd5

@dimpase
Copy link
Member Author

dimpase commented Mar 16, 2019

comment:3

I don't know why it has taken so long to get started with this, to link together all these loose spkg docs in SAGE_LOCAL - something one might not even notice otherwise.

At least now SageNB docs are nicely linked - and available as HTML, in particular this will be there on the website, I suppose.

Let's get it in quickly, and add more on a followup ticket.

@kiwifb
Copy link
Member

kiwifb commented Mar 16, 2019

comment:4

Nice intentions I guess. From the point of view of sage in isolation it looks ok.

I don't use configure in sage-on-gentoo, so I would rather want something that applies from setup.py. Link to other packages documentation, all distros will probably want to patch. Note how it is all over the place? There is no way we let things be that messy. Documentation lives under some form of /usrshare/doc/, /usr/share/$PKG/doc and variations are frowned upon. But that's not easily fixable without you guys deciding on a standard and applying it across the board. We can wait a few more years before getting there.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 17, 2019

Changed commit from 13c2fd5 to 85299a3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 17, 2019

Branch pushed to git repo; I updated commit sha1. New commits:

85299a3linking pplpy docs

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:6

It seems to be a tall order to harmonise naming schemes and locations for docs of all the Sage packages.

I'd rather take what each package provides and in spkg-configure.m4 record this location into a variable (perhaps if the package is not built, but a system version used, then no doc link needs to be generated at all).

Another important reason for having this is that authors of external packages sometimes are annoyed by Sage incorporating their work silently. This showing/linking of docs will make it less silent...

@jhpalmieri
Copy link
Member

comment:7

As fbissey said, what about doing this with Python instead of configure? Perhaps in src/sage_setup/docbuild/__init__.py we could modify index.rst, or take index.rst.in as input and write index.rst as output.

Or if it's just reference/index.rst that's relevant, it could be done in reference/conf.py.

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:8

Replying to @jhpalmieri:

As fbissey said, what about doing this with Python instead of configure?

Why? What's wrong with doing it at configuration time?
Should we redo the whole Sage building process with Python only? :-)

Mind you, Python does not have tools for this, autoconf does, as you see.

Perhaps in src/sage_setup/docbuild/__init__.py we could modify index.rst, or take index.rst.in as input and write index.rst as output.

Or if it's just reference/index.rst that's relevant, it could be done in reference/conf.py.

@kiwifb
Copy link
Member

kiwifb commented Mar 17, 2019

comment:9

Replying to @dimpase:

Replying to @jhpalmieri:

As fbissey said, what about doing this with Python instead of configure?

Why? What's wrong with doing it at configuration time?
Should we redo the whole Sage building process with Python only? :-)

That, you see, is the result of conflating "sage the distribution" with "sage the software". A confusion made easier by the fact that sage the software is not distributed as a proper package like the rest of its dependencies. The top configure is really mostly for sage the distribution and mingling the top level configure to stuff in sage the software means that you are not wanting sage the software to be pip installable ever.

Mind you, Python does not have tools for this, autoconf does, as you see.

Perhaps in src/sage_setup/docbuild/__init__.py we could modify index.rst, or take index.rst.in as input and write index.rst as output.

Or if it's just reference/index.rst that's relevant, it could be done in reference/conf.py.

Yes I am aware that what you are thinking of is easy with autotools but not trivial with python. But sometimes doing the easy stuff is just painting yourself in a corner in the long run.

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:10

We don't have a special manual for Sage the software (sagelib), only for Sage the distro. This ticket makes no attempt to change this situation, it merely improves the existing reference manual, in particular corrects the fact that SageNB docs are no longer available on http://doc.sagemath.org.

One would surely welcome an effort to partition the docs between sagelib and Sage the distro, but arguably a large part of the top index.rst, including everything on this ticket, would not belong to sagelib docs.

@dimpase

This comment has been minimized.

@timokau
Copy link
Contributor

timokau commented Mar 17, 2019

comment:12

Replying to @kiwifb:

Link to other packages documentation, all distros will probably want to patch. Note how it is all over the place? There is no way we let things be that messy. Documentation lives under some form of /usrshare/doc/, /usr/share/$PKG/doc and variations are frowned upon.

+1, could we make the individual doc locations configurable?

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:13

Replying to @timokau:

Replying to @kiwifb:

Link to other packages documentation, all distros will probably want to patch. Note how it is all over the place? There is no way we let things be that messy. Documentation lives under some form of /usrshare/doc/, /usr/share/$PKG/doc and variations are frowned upon.

+1, could we make the individual doc locations configurable?

individual packages have their own ideas where the docs should go. Mostly it is
either /usr/share/$PKG/doc or /usr/share/doc/$PKG, but not always. E.g. cmake puts docs in $prefix/doc. They also don't always have a topmost index.html, or quite often only provide pdf docs. Some probably have it configurable, some (most?) probably not.

Some packages have only little English documentation, e.g. giac.

This ticket is not meant to sort this huge mess out. It rather fixes most glaring omissions and provides a heads-up on docs that otherwise merely collect digital dust in $SAGE_LOCAL.

@timokau
Copy link
Contributor

timokau commented Mar 17, 2019

comment:14

Replying to @dimpase:

individual packages have their own ideas where the docs should go

I'm not talking about configuring where they are installed (which is a sage-the-distribution concern), but where sage looks for them when they are linked. Distributions don't install the docs of dependencies through sage's build system.

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:15

Replying to @timokau:

Replying to @dimpase:

individual packages have their own ideas where the docs should go

I'm not talking about configuring where they are installed (which is a sage-the-distribution concern), but where sage looks for them when they are linked. Distributions don't install the docs of dependencies through sage's build system.

I can give templates used in index.rst.in more generic names. Please suggest what would be suitable.

@timokau
Copy link
Contributor

timokau commented Mar 17, 2019

comment:16

Being able to override them with SAGENB_DOC, SINGULAR_DOC etc. would be helpful. I also currently don't use the ./configure script, but I don't see any reason I couldn't add that.

I agree that it is a step backwards from the "pip-installability" goal though.

@dimpase
Copy link
Member Author

dimpase commented Mar 17, 2019

comment:17

Replying to @timokau:

Being able to override them with SAGENB_DOC, SINGULAR_DOC etc. would be helpful. I also currently don't use the ./configure script, but I don't see any reason I couldn't add that.

OK, will do.

I agree that it is a step backwards from the "pip-installability" goal though.

It is not really so, as the top level reference manual already has things that are not about sagelib, e.g. some of it are to be in the development manual.

I agree though that it's desirable to add one more level to Sage distro docs, something akin to
http://doc.sagemath.org/

@jhpalmieri
Copy link
Member

comment:18

Replying to @dimpase:

Replying to @jhpalmieri:

As fbissey said, what about doing this with Python instead of configure?

Why? What's wrong with doing it at configuration time?
Should we redo the whole Sage building process with Python only? :-)

Mind you, Python does not have tools for this, autoconf does, as you see.

It's a search-and-replace; I think Python can handle it. Google led me to this, for example, for a generic search-and-replace:

import fileinput

for line in fileinput.FileInput(filename, inplace=True):
    print(line.replace(text_to_search, replacement_text))

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 2, 2021

Changed reviewer from Dima Pasechnik to none

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 2, 2021

Changed branch from u/jhpalmieri/doc/docrefs to none

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 2, 2021

Changed commit from dab737d to none

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 2, 2021

Changed author from Dima Pasechnik, John Palmieri to none

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title links to external docs in main reference index.rst Use sphinx.ext.extlinks to add Sphinx roles for links to external package docs Jan 2, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 13, 2021

comment:85

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@embray
Copy link
Contributor

embray commented Feb 26, 2021

comment:89

Just bikeshedding, but I don't know why the verbose names like :spkg_giac_doc: and not just something like :giac:. I understand giac_doc is supposed to refer to an SPKG specifically for the GIAC docs, but in the context of the documentation that should be a given anyways.

Also how does this relate to other Python packages that already use Sphinx, and can use intersphinx instead?

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 26, 2021

comment:90

Replying to @embray:

Just bikeshedding, but I don't know why the verbose names like :spkg_giac_doc: and not just something like :giac:.

Fine with me to simplify these names.

Also how does this relate to other Python packages that already use Sphinx, and can use intersphinx instead?

The present ticket here is easier and can set the naming convention.

Packages where we can do intersphinx should use a compatible naming convention.

@mkoeppe
Copy link
Contributor

mkoeppe commented Jul 19, 2021

comment:91

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 30, 2024
…ppl, qepcad, scip, singular, soplex

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

We create a standard way to refer to the online manuals of these
packages, which are generated by tools other than Sphinx and therefore
cannot be linked to using Intersphinx.

This extends what has been already done with Pari.

Examples:
- [Examples in the Developer Guide](https://deploy-preview-37598--
sagemath.netlify.app/html/en/developer/sage_manuals#hyperlinks)

Fixes sagemath#27495.

Outside of the scope of this PR:
- adding such extlinks everywhere
- working with upstream projects to upgrade to better documentation
tools
- projects that can be linked to using Intersphinx; that's sagemath#37575
- any consideration how to link instead to local copies of those
manuals, whether installed from SPKG or system packages.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37598
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe, Max Horn
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants