Skip to content

Commit d4b4235

Browse files
committed
docs: better interlinks docs
1 parent 54d3478 commit d4b4235

File tree

3 files changed

+65
-22
lines changed

3 files changed

+65
-22
lines changed

docs/_quarto.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ website:
7474
contents:
7575
- get-started/basic-docs.qmd
7676
- get-started/crossrefs.qmd
77+
- get-started/interlinks.qmd
7778
- get-started/sidebar.qmd
7879
- section: "Advanced"
7980
contents:
8081
- get-started/docstrings.qmd
8182
- get-started/renderers.qmd
82-
- get-started/interlinks.qmd
8383
- section: "Extra Topics"
8484
contents:
8585
- get-started/architecture.qmd

docs/get-started/crossrefs.qmd

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,46 @@ jupyter:
77
name: python3
88
---
99

10-
Coming soon!
11-
1210
## Linking by path
1311

14-
You can link to function docs by using the path to the generated documentation file:
15-
16-
``[get_object](/reference/get_object.qmd)``
12+
You can use [quarto's markdown linking syntax](https://quarto.org/docs/authoring/markdown-basics.html#links-images)
13+
to link to function docs, by using the path to the generated documentation file.
1714

15+
Here are some examples:
1816

19-
* /reference/
17+
| code | result |
18+
| ---- | ------ |
19+
| ``[get_object](/reference/get_object.qmd)`` | [get_object](/reference/get_object.qmd) |
20+
| ``[link text](/reference/MdRenderer.qmd)`` | [link text](/reference/MdRenderer.qmd) |
2021

2122

2223
## Linking by function name
2324

25+
Use quartodoc's [interlinking filter](./interlinks.qmd) to link to functions using only their names:
26+
27+
| code | result |
28+
| ---- | ------ |
29+
| ``[](`quartodoc.get_object`)`` | [](`quartodoc.get_object`) |
30+
31+
Notice that the link above puts the function name in backticks, rather than using
32+
the path to its documentation: `` `quartodoc.get_object` ``.
33+
34+
You can also use this approach to link to other documentation sites.
35+
For example, including links to quartodoc, or https://docs.python.org/3 using function names.
36+
37+
See the [interlinks documentation](./interlinks.qmd) for set up and usage.
38+
2439

2540
## The "See Also" section
2641

42+
A major goal of quartodoc is to automatically turn text in the "See Also" section
43+
of docstrings into links.
44+
45+
See [this issue](https://github.com/machow/quartodoc/issues/21) for more details
46+
on parsing See Also sections, and [this issue](https://github.com/machow/quartodoc/issues/22)
47+
on turning type annotations into links.
2748

49+
## Type annotations in docstrings
2850

51+
This is planned, but currently unimplemented. See [this issue](https://github.com/machow/quartodoc/issues/22)
52+
on turning type annotations into links.

docs/get-started/interlinks.qmd

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,29 @@ jupyter:
99

1010

1111
The interlinks filter allows you to provide crossreferences within and between documentation.
12-
It requires of two parts:
12+
It consists of three pieces:
1313

14-
1. Specifying sphinx inventories for the filter to use in your quarto configuration.
15-
2. Generating sphinx inventories for the filter to use.
14+
1. **Install**: adding the extension to your quarto project.
15+
1. **Configure**: specifying sphinx inventories for the filter to use in your `_quarto.yml` config.
16+
2. **Run**: Generating sphinx inventories for the filter to use.
1617

17-
## What is a sphinx inventory file?
18-
19-
Sphinx inventory files provide information about where the documentation for
20-
functions live on a website.
18+
## Installing
2119

22-
Most sphinx sites name them `object.inv`:
20+
Use the [quarto add command](https://quarto.org/docs/extensions/filters.html#distribution)
21+
to install the interlinks filter:
2322

24-
* numpy: https://numpy.org/doc/stable/objects.inv
25-
* python: https://docs.python.org/3/objects.inv
23+
```bash
24+
quarto add machow/quartodoc
25+
```
2626

27+
:::{.callout-note}
28+
The code for the filter can be found in quartodoc's
29+
[_extension folder](https://github.com/machow/quartodoc/tree/main/_extensions/interlinks)
30+
:::
2731

2832
## Configuring the interlinks filter
2933

30-
Configure the filter in `_quarto.yml` or on specific pages:
34+
Configure the filter in `_quarto.yml` or on specific pages, by adding these sections:
3135

3236
```yaml
3337
filters:
@@ -41,16 +45,17 @@ interlinks:
4145
url: https://docs.python.org/3/
4246
```
4347
44-
Notice 3 important pieces in this config:
48+
Notice 2 important pieces in this config:
4549
4650
* The `numpy` and `python` fields indicate that we're getting inventories for the
4751
library numpy, and python builtin libraries.
4852
* The `url` fields indicate where inventory files can be found.
49-
* The `fallback` field indicates where we should save the file, so we don't need
50-
to download it repeatedly.
5153

54+
By default, downloaded inventory files will be saved in the `_inv` folder of your
55+
documentation directory.
5256

53-
## Generating sphinx inventories
57+
58+
## Running the interlinks filter
5459

5560
First, build the reference for your own site, which includes an objects.json inventory:
5661

@@ -127,6 +132,20 @@ For example, python.org has two entries for the name `print`.
127132
| py | function | [``[](:py:function:`print`)``](:py:function:`print`) |
128133

129134

135+
## What is a sphinx inventory file?
136+
137+
Sphinx inventory files provide information about where the documentation for
138+
functions live on a website.
139+
140+
Most sphinx sites name them `object.inv`:
141+
142+
* numpy: https://numpy.org/doc/stable/objects.inv
143+
* python: https://docs.python.org/3/objects.inv
144+
145+
See the [sphobjinv docs](https://sphobjinv.readthedocs.io/en/stable/) for thorough
146+
details on these files, and how they're used in sphinx.
147+
148+
130149
## More information
131150

132151
Under the hood, quarto doc generates sphinx inventories for an API e using [create_inventory](/api/#sec-create_inventory),

0 commit comments

Comments
 (0)