Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Try to fix code links in docs #183

Merged
merged 6 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependencies:
- sphinx-panels
- sphinx-autosummary-accessors
- sphinx-book-theme >= 0.0.38
- nbsphinx
- sphinxcontrib-srclinks
- pydata-sphinx-theme>=0.4.3
- numpydoc
- ipython
Expand Down
18 changes: 14 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import inspect
import os
import sys

Expand Down Expand Up @@ -41,6 +42,7 @@
"numpydoc",
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.linkcode",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
Expand All @@ -50,6 +52,8 @@
"sphinx_autosummary_accessors",
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
"nbsphinx",
"sphinxcontrib.srclinks",
]

extlinks = {
Expand All @@ -76,6 +80,11 @@
copyright = "2021 onwards, Tom Nicholas and its Contributors"
author = "Tom Nicholas"

html_show_sourcelink = True
srclink_project = "https://github.com/xarray-contrib/datatree"
srclink_branch = "main"
srclink_src_path = "docs/source"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
Expand Down Expand Up @@ -127,6 +136,7 @@

intersphinx_mapping = {
"python": ("https://docs.python.org/3.8/", None),
"numpy": ("https://numpy.org/doc/stable", None),
"xarray": ("https://xarray.pydata.org/en/stable/", None),
}

Expand All @@ -142,7 +152,7 @@
html_theme_options = {
"repository_url": "https://github.com/xarray-contrib/datatree",
"repository_branch": "main",
"path_to_docs": "doc",
"path_to_docs": "docs/source",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
Expand Down Expand Up @@ -334,12 +344,12 @@ def linkcode_resolve(domain, info):
else:
linespec = ""

fn = os.path.relpath(fn, start=os.path.dirname(xarray.__file__))
fn = os.path.relpath(fn, start=os.path.dirname(datatree.__file__))

if "+" in xarray.__version__:
if "+" in datatree.__version__:
return f"https://github.com/xarray-contrib/datatree/blob/main/datatree/{fn}{linespec}"
else:
return (
f"https://github.com/xarray-contrib/datatree/blob/"
f"v{datatree.__version__}/xarray/{fn}{linespec}"
f"v{datatree.__version__}/datatree/{fn}{linespec}"
)
2 changes: 2 additions & 0 deletions docs/source/data-structures.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

.. _data structures:

Data Structures
Expand Down
4 changes: 3 additions & 1 deletion docs/source/hierarchical-data.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

.. _hierarchical-data:

Working With Hierarchical Data
Expand Down Expand Up @@ -31,7 +33,7 @@ Examples of data which one might want organise in a grouped or hierarchical mann

or even any combination of the above.

Often datasets like this cannot easily fit into a single ``xarray.Dataset`` object,
Often datasets like this cannot easily fit into a single :py:class:`xarray.Dataset` object,
or are more usefully thought of as groups of related ``xarray.Dataset`` objects.
For this purpose we provide the :py:class:`DataTree` class.

Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

Datatree
========

Expand Down
2 changes: 2 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

============
Installation
============
Expand Down
2 changes: 2 additions & 0 deletions docs/source/io.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

.. _io:

Reading and Writing Files
Expand Down
6 changes: 4 additions & 2 deletions docs/source/quick-overview.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.. currentmodule:: datatree

##############
Quick overview
##############

DataTrees
---------

:py:class:`DataTree` is a tree-like container of ``DataArray`` objects, organised into multiple mutually alignable groups.
You can think of it like a (recursive) ``dict`` of ``Dataset`` objects.
:py:class:`DataTree` is a tree-like container of :py:class:`xarray.DataArray` objects, organised into multiple mutually alignable groups.
You can think of it like a (recursive) ``dict`` of :py:class:`xarray.Dataset` objects.

Let's first make some example xarray datasets (following on from xarray's
`quick overview <https://docs.xarray.dev/en/stable/getting-started-guide/quick-overview.html>`_ page):
Expand Down
1 change: 1 addition & 0 deletions docs/source/terminology.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. currentmodule:: datatree

.. _terminology:

This page extends `xarray's page on terminology <https://docs.xarray.dev/en/stable/user-guide/terminology.html>`_.
Expand Down
2 changes: 2 additions & 0 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. currentmodule:: datatree

========
Tutorial
========
Expand Down
2 changes: 2 additions & 0 deletions docs/source/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Bug fixes

- Fix bug with :py:meth:`DataTree.relative_to` method (:issue:`133`, :pull:`160`).
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Fix links to API docs in all documentation (:pull:`183`).
By `Tom Nicholas <https://github.com/TomNicholas>`_.

Documentation
~~~~~~~~~~~~~
Expand Down