Skip to content

Commit

Permalink
tweak doc-build so test is more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Dec 15, 2020
1 parent 78194d6 commit ac08486
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions dash_slicer/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import dash_slicer


md_seperator = "<!--- The below is autogenerated - do not edit --->" # noqa


def dedent(text):
"""Dedent a docstring, removing leading whitespace."""
lines = text.lstrip().splitlines()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from dash_slicer.docs import get_reference_docs
from dash_slicer.docs import get_reference_docs, md_seperator


HERE = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -18,7 +18,7 @@ def test_that_reference_docs_in_readme_are_up_to_date():
assert os.path.isfile(filename)
with open(filename, "rb") as f:
text = f.read().decode()
_, _, ref = text.partition("## Reference")
_, _, ref = text.partition(md_seperator)
ref1 = ref.strip().replace("\r\n", "\n")
ref2 = get_reference_docs().strip()
assert (
Expand Down
8 changes: 3 additions & 5 deletions update_docs_in_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import os
from dash_slicer.docs import get_reference_docs
from dash_slicer.docs import get_reference_docs, md_seperator


HERE = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -13,17 +13,15 @@
def write_reference_docs():
"""Write the reference docs to the README."""
# Prepare
header = "## Reference"
note = "<!--- The below is autogenerated - do not edit --->"
filename = os.path.join(HERE, "README.md")
assert os.path.isfile(filename), "README.md not found"
# Load first part of the readme
with open(filename, "rb") as f:
text = f.read().decode()
text1, _, _ = text.partition(header)
text1, _, _ = text.partition(md_seperator)
text1 = text1.strip()
# Create second part of the readme
text2 = "\n\n\n" + header + "\n\n" + note + "\n\n" + get_reference_docs()
text2 = "\n\n" + md_seperator + "\n\n" + get_reference_docs()
if "\r" in text1:
text2 = text2.replace("\n", "\r\n")
# Wite
Expand Down

0 comments on commit ac08486

Please sign in to comment.