Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.
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
10 changes: 7 additions & 3 deletions ci/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ dependencies:
- python>=3.8
- netcdf4
- scipy
- sphinx
- sphinx>=4.2.0
- sphinx-copybutton
- numpydoc
- sphinx-panels
- sphinx-autosummary-accessors
- sphinx-book-theme >= 0.0.38
- pydata-sphinx-theme>=0.4.3
- numpydoc
- ipython
- h5netcdf
- zarr
- pip:
- git+https://github.com/xarray-contrib/datatree
- pangeo-sphinx-book-theme
- sphinxext-rediraffe
- sphinxext-opengraph
- xarray>=2022.05.0.dev0
8 changes: 7 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) sou
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html rtdhtml dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " rtdhtml Build html using same settings used on ReadtheDocs"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
Expand Down Expand Up @@ -54,6 +55,11 @@ html:
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

rtdhtml:
$(SPHINXBUILD) -T -j auto -E -W --keep-going -b html -d $(BUILDDIR)/doctrees -D language=en . $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
Expand Down
66 changes: 59 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx.ext.napoleon",
"sphinx_copybutton",
"sphinxext.opengraph",
"sphinx_autosummary_accessors",
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
]
Expand Down Expand Up @@ -131,7 +134,11 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "pangeo_sphinx_book_theme"
html_theme = "sphinx_book_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"repository_url": "https://github.com/xarray-contrib/datatree",
"repository_branch": "main",
Expand All @@ -141,11 +148,6 @@
"use_edit_page_button": True,
}

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

Expand All @@ -168,7 +170,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
html_static_path = ["_static"]

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down Expand Up @@ -291,3 +293,53 @@

# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False


# based on numpy doc/source/conf.py
def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
if domain != "py":
return None

modname = info["module"]
fullname = info["fullname"]

submod = sys.modules.get(modname)
if submod is None:
return None

obj = submod
for part in fullname.split("."):
try:
obj = getattr(obj, part)
except AttributeError:
return None

try:
fn = inspect.getsourcefile(inspect.unwrap(obj))
except TypeError:
fn = None
if not fn:
return None

try:
source, lineno = inspect.getsourcelines(obj)
except OSError:
lineno = None

if lineno:
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
else:
linespec = ""

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

if "+" in xarray.__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}"
)
2 changes: 2 additions & 0 deletions docs/source/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Documentation

- Added ``Reading and Writing Files`` page. (:pull:`158`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Changed docs theme to match xarray's main documentation. (:pull:`173`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down