-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
258 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extensions = ["sphinxcontrib.bibtex", "autoapi.extension"] | ||
exclude_patterns = ["_build"] | ||
bibtex_bibfiles = ["test.bib"] | ||
autoapi_python_class_content = "both" # document __init__ method too | ||
autoapi_dirs = ["some_module/"] | ||
autoapi_keep_files = True # useful for debugging | ||
autoapi_add_toctree_entry = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
index | ||
===== | ||
|
||
.. toctree:: | ||
|
||
autoapi/some_module/index | ||
|
||
.. bibliography:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Some module.""" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Docstring for some_module. :footcite:`testmodule` | ||
.. footbibliography:: | ||
""" | ||
|
||
|
||
def func(funcarg): | ||
"""Docstring for function func. | ||
Long description goes here. See :footcite:`testfunc`. | ||
:param funcarg: Docstring for parameter. :footcite:`testfuncarg` | ||
.. footbibliography:: | ||
""" | ||
|
||
|
||
a = 1 | ||
"""Docstring for variable a. | ||
Long description goes here. See :footcite:`testdata`. | ||
.. footbibliography:: | ||
""" | ||
|
||
|
||
class Foo: | ||
"""Docstring for class Foo. | ||
Long description goes here. See :footcite:`testclass`. | ||
.. footbibliography:: | ||
""" | ||
|
||
b = 2 | ||
"""Docstring for class attribute b. | ||
Long description goes here. See :footcite:`testclassattr`. | ||
.. footbibliography:: | ||
""" | ||
|
||
def __init__(self, initarg): | ||
"""Docstring for constructor. | ||
Long description goes here. See :footcite:`testinit`. | ||
:param initarg: Docstring for parameter. :footcite:`testinitarg` | ||
.. footbibliography:: | ||
""" | ||
|
||
self.c = 3 | ||
"""Docstring for instance attribute c. | ||
Long description goes here. See :footcite:`testinstanceattr` | ||
.. footbibliography:: | ||
""" | ||
|
||
def method(self, methodarg): | ||
"""Docstring for method. | ||
Long description goes here. See :footcite:`testmethod`. | ||
:param methodarg: Docstring for parameter. :footcite:`testmethodarg` | ||
.. footbibliography:: | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@Misc{testmodule, | ||
author = {A. One}, | ||
title = {Een}, | ||
} | ||
@Misc{testfunc, | ||
author = {B. Two}, | ||
title = {Twee}, | ||
} | ||
@Misc{testfuncarg, | ||
author = {C. Three}, | ||
title = {Drie}, | ||
} | ||
@Misc{testdata, | ||
author = {D. Four}, | ||
title = {Vier}, | ||
} | ||
@Misc{testclass, | ||
author = {E. Five}, | ||
title = {Vijf}, | ||
} | ||
@Misc{testclassattr, | ||
author = {F. Six}, | ||
title = {Zes}, | ||
} | ||
@Misc{testinstanceattr, | ||
author = {G. Seven}, | ||
title = {Zeven}, | ||
} | ||
@Misc{testinit, | ||
author = {H. Eight}, | ||
title = {Acht}, | ||
} | ||
@Misc{testinitarg, | ||
author = {I. Nine}, | ||
title = {Negen}, | ||
} | ||
@Misc{testmethod, | ||
author = {J. Ten}, | ||
title = {Tien}, | ||
} | ||
@Misc{testmethodarg, | ||
author = {K. Eleven}, | ||
title = {Elf}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
footcite | ||
======== | ||
|
||
.. automodule:: test.some_module_footcite | ||
.. automodule:: test.some_module.footcite | ||
:members: | ||
|
||
.. footbibliography:: |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Docstring for some_module. :cite:`testmodule`""" | ||
|
||
|
||
def func(funcarg): | ||
"""Docstring for function func. | ||
Long description goes here. See :cite:`testfunc`. | ||
:param funcarg: Docstring for parameter. :cite:`testfuncarg` | ||
""" | ||
|
||
|
||
a = 1 | ||
"""Docstring for variable a. | ||
Long description goes here. See :cite:`testdata`. | ||
""" | ||
|
||
|
||
class Foo: | ||
"""Docstring for class Foo. | ||
Long description goes here. See :cite:`testclass`. | ||
""" | ||
|
||
b = 2 | ||
"""Docstring for class attribute b. | ||
Long description goes here. See :cite:`testclassattr`. | ||
""" | ||
|
||
def __init__(self, initarg): | ||
"""Docstring for constructor. | ||
Long description goes here. See :cite:`testinit` | ||
:param initarg: Docstring for parameter. :cite:`testinitarg` | ||
""" | ||
|
||
self.c = 3 | ||
"""Docstring for instance attribute c. | ||
Long description goes here. See :cite:`testinstanceattr`. | ||
""" | ||
|
||
def method(self, methodarg): | ||
"""Docstring for method. | ||
Long description goes here. See :cite:`testmethod`. | ||
:param methodarg: Docstring for parameter. :cite:`testmethodarg` | ||
""" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
test_autodoc | ||
~~~~~~~~~~~~ | ||
Test with autodoc. | ||
""" | ||
|
||
from test.common import ( | ||
html_citation_refs_single, | ||
html_citations, | ||
html_footnote_refs, | ||
html_footnotes, | ||
) | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.sphinx("html", testroot="autoapi") | ||
def test_autoapi(app, warning) -> None: | ||
app.build() | ||
assert not warning.getvalue() | ||
root = (app.outdir / "index.html").read_text() | ||
output = (app.outdir / "autoapi/some_module/cite/index.html").read_text() | ||
labels = [ | ||
"One", | ||
"Two", | ||
"Thr", | ||
"Fou", | ||
"Fiv", | ||
"Six", | ||
"Sev", | ||
"Eig", | ||
"Nin", | ||
"Ten", | ||
"Ele", | ||
] | ||
titles = [ | ||
"Een", | ||
"Twee", | ||
"Drie", | ||
"Vier", | ||
"Vijf", | ||
"Zes", | ||
"Zeven", | ||
"Acht", | ||
"Negen", | ||
"Tien", | ||
"Elf", | ||
] | ||
for label, title in zip(labels, titles): | ||
assert len(html_citation_refs_single(label=label).findall(output)) == 1 | ||
assert len(html_citations(label=label).findall(root)) == 1 | ||
match_ref = html_citation_refs_single(label=label).search(output) | ||
match = html_citations(label=label).search(root) | ||
assert match_ref | ||
assert match | ||
assert match_ref.group("refid") == match.group("id_") | ||
assert title in match.group("text") | ||
# no backrefs as citations are in other document | ||
# assert match_ref.group("id_") == match.group("backref") | ||
output2 = (app.outdir / "autoapi/some_module/footcite/index.html").read_text() | ||
assert len(html_footnote_refs().findall(output2)) == 11 | ||
for title in titles: | ||
text = ".*" + title + ".*" | ||
assert len(html_footnotes(text=text).findall(output2)) == 1 | ||
match = html_footnotes(text=text).search(output2) | ||
assert match | ||
id_ = match.group("id_") | ||
assert len(html_footnote_refs(refid=id_).findall(output2)) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters