Skip to content

Commit

Permalink
Tweak r doc build
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Feb 18, 2025
1 parent 85836d2 commit 9a32d85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 4 additions & 2 deletions clients/R/convert_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ for (f in files) {
# read .Rd file and convert to markdown
rd <- rd2markdown::get_rd(file = file.path(".", "man", f))
md <- rd2markdown::rd2markdown(rd, fragments = c())
# replaces the headers with more appropriate levels for embedding
md_indented <- gsub("(#+)", "\\1##", md)

# write it to the docs folder
writeLines(md, file.path("..", "..", "docs", "languages", "_r", paste0(name,
".md")))
writeLines(md_indented, file.path("..", "..", "docs", "languages", "_r",
paste0(name, ".md")))

}
14 changes: 4 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import datetime
import re

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand Down Expand Up @@ -132,12 +131,13 @@
import pathlib

RUNNING_IN_CI = os.environ.get("CI") or os.environ.get("READTHEDOCS")
BASE_DIR = pathlib.Path(__file__).parent.parent

try:
print("Building Julia doc")
subprocess.run(
["julia", "--project=.", "./make.jl"],
cwd=pathlib.Path(__file__).parent.parent / "clients" / "julia" / "docs",
cwd=BASE_DIR / "clients" / "julia" / "docs",
check=True,
)
except Exception as e:
Expand All @@ -151,16 +151,10 @@
print("Building R doc")
subprocess.run(
["Rscript", "convert_docs.R"],
cwd=pathlib.Path(__file__).parent.parent / "clients" / "R",
cwd=BASE_DIR / "clients" / "R",
check=True,
)

# replaces the headers with more appropriate levels for embedding
for f in (pathlib.Path(__file__).parent / "languages" / "_r").iterdir():
text = f.read_text()
text = re.sub(r"(#+) ", r"##\1 ", text)
f.write_text(text)

except Exception as e:
# fail loudly in Github Actions
if RUNNING_IN_CI:
Expand Down Expand Up @@ -188,7 +182,7 @@
yarn = os.getenv("YARN", "yarn").split()
ret = subprocess.run(
yarn + ["--silent", "doc"],
cwd=pathlib.Path(__file__).parent.parent / "clients" / "typescript",
cwd=BASE_DIR / "clients" / "typescript",
check=True,
capture_output=True,
text=True,
Expand Down

0 comments on commit 9a32d85

Please sign in to comment.