Skip to content
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

readthedocs: show readme #400

Merged
merged 5 commits into from
Mar 22, 2020
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
1 change: 0 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
python md2rst.py
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 4 additions & 0 deletions doc/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Enlarge to max-width 900px (default: 800px) */
.wy-nav-content {
max-width: 900px !important;
}
10 changes: 8 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
# The full version, including alpha/beta/rc tags
release = 'latest'

# -- Custom pre-build --------------------------------------------------------

import subprocess

subprocess.run(['python', 'md2rst.py'])

# -- General configuration ---------------------------------------------------

Expand All @@ -35,7 +40,7 @@
'recommonmark',
'sphinx.ext.autosummary',
'sphinx_markdown_tables',
'nbsphinx'
'nbsphinx',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -73,7 +78,8 @@
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

def setup(app):
app.add_stylesheet('custom.css')
# 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".
Expand Down
14 changes: 10 additions & 4 deletions doc/md2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ def absolute_links(txt):
return txt


txt = absolute_links(read("../README.md"))
txt = m2r.convert(txt)
with open("_static/README.rst", 'w') as f:
f.write(txt)
def md2rst(source: str, target: str):
txt = absolute_links(read(source))
txt = m2r.convert(txt)
with open(target, 'w') as f:
f.write(txt)


if __name__ == '__main__':
# parse readme
md2rst('../README.md', '_static/README.rst')
5 changes: 5 additions & 0 deletions tests/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pandas as pd
import tempfile
import pytest
import os

import petab
from petab import conditions
Expand Down Expand Up @@ -44,6 +45,8 @@ def test_get_condition_df():
with pytest.raises(KeyError):
petab.get_condition_df(file_name)

os.remove(file_name)

# with ids
condition_df = pd.DataFrame(data={
CONDITION_ID: ['condition1', 'condition2'],
Expand All @@ -58,6 +61,8 @@ def test_get_condition_df():
df = petab.get_condition_df(file_name).replace(np.nan, '')
assert (df == condition_df.set_index(CONDITION_ID)).all().all()

os.remove(file_name)

# test other arguments
assert (petab.get_condition_df(condition_df) == condition_df).all().all()
assert petab.get_condition_df(None) is None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_concat_measurements():

def test_get_obervable_ids(petab_problem): # pylint: disable=W0621
"""Test if observable ids functions returns correct value."""
assert set(petab_problem.get_observable_ids()) == set(['observable_1'])
assert set(petab_problem.get_observable_ids()) == {'observable_1'}


def test_parameter_properties(petab_problem): # pylint: disable=W0621
Expand Down