-
Notifications
You must be signed in to change notification settings - Fork 50
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
Reference external MyST sites with labels and standard reference syntax (xref) #1111
Comments
Related:
We could use the references section to define new "schemes" references:
compass: compass.executablebooks.org
2i2c: 2i2c.org/docs/infrastructure
gh_myst:
url: https://github.com/executablebooks/mystmd
kind: github
|
I'm a 👍 on e.g. <xref:gh_myst:#1111> For MyST-MD, I feel that we want to unify intersphinx and non-intersphinx xrefs (i.e. MyST sites) under a references table, using explicit When it comes to different kinds of xrefs, e.g. GitHub, I am not against a single scheme per type of xref, e.g. <gh:executablebooks/myst#1111> or <gh:executablebooks/myst#1111> These kind of schemes would be inherently more understandable (i.e. we know But, this is all very hot off the press, so I'll keep thinking on it. |
In talking through with @fwkoch today, these were our notes on where we are headed shortly. This should allow for minimal changes to our config/reference syntax, a new file that we write out to have myst-reference declarations, and how to use those in markdown (going with a protocol per definition with Exposing cross-references: write out a myst-friendly xref object, which is just JSON. This should be very similar to the object.inv. In addition to the objects.inv that we write to the site folder, write a version: 1
myst: 1.2.1
references:
- identifier: fig:abc
kind: figure
html_id: fig-abc # This is optional, and only included if different
url: page
data: some/other/page.json
implicit: true This allows us to get the myst To reference these, your project:
references:
# All of these should just be able to be specified with just the URL as a string
jb:
kind: intersphinx
url: https://jupyterbook.org
mystmd:
kind: myst
url: https://mystmd.org
gh-mt:
kind: github-issue
url: https://github.com/executablebooks/myst-theme These define url protocols, with the following resolved fields This allows the following URLs:
This will create a AST for a link similar to: {
"type": "crossReference",
"kind": "heading",
"identifier": "setex-headings",
"label": "setex-headings",
"children": [
{
"type": "text",
"value": "Setext Headings",
}
],
"html_id": "setex-headings",
"remote": true,
"url": "/commonmark",
"dataUrl": "https://remote.url/commonmark.json",
}, At this point, we shouldn't need any changes from the theme as long as the CORS is set correctly on the JSON response. |
@rowanc1, @fwkoch, and I had a short meeting to think on the user experience side of things (now that the hard work has been done by the aforementioned two). Briefly, there are two syntax suggestions:
i.e., does the xref source act as a scheme or a hostname? There were the following "topics" of conversation identified:
We had some good discussion, and settled on using an explicit
The There is already an example of where we've thought about this; the
We can choose the meaning of the path. For example, with
etc. Note The We settled on a hybrid "URL"-style locator (although at the time the above discussion of URL-URN-URI was missing), which probably reflects the way we think about xrefs:
With this syntax, we might need to think about how domains are represented. Maybe we need a special scheme The difference to a "URL" is that we don't require an @rowanc1 also pointed out that in the future, we may have MyST-authored content living at a DOI address, meaning that we could define a DOI as an xref source in order to pull out structured assets! Footnotes
|
In case it's useful this is how Sphinx seems to recommend doing cross refs with intersphinx nowadays https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#role-external It's with a dedicated role that follows a form like A small nitpick: does it need to be the full "xref" or is it reasonable to use something shorter like "xr" or a symbol like "@"? Just trying to think of how to minimize visual clutter and keystrokes but it's not a deal breaker |
Thanks for the writeup @agoose77 I foresee a follow up MEP, @fwkoch and I have implemented it! Merging in the first PR shortly, the following still needs to be improved:
|
@rowanc1 I think this initial implementation is complete as far as the issue brief. I'll open a new issue to track some of the remaining TODOs. |
(Closed by #1180) |
Currently, allow for cross-referencing many kinds of external content. However, we do not support cross-references for other MyST sites.
It would be useful if you could cross-reference another MyST site's content via labels and a unique identifier for that site, similar to how the Intersphinx referencing syntax works.
For example, in MyST site 1, define a link like:
(myLabel)= ### My section Some text
And in MyST site 2, have configuration like:
And in content, something like:
The text was updated successfully, but these errors were encountered: