extract documentation URL from frozen directory README.rst
This commit is contained in:
parent
e08502fa85
commit
f8922a56f9
@ -70,6 +70,9 @@ frozen_excludes = ["examples", "docs", "tests", "utils", "conf.py", "setup.py"]
|
|||||||
"""Files and dirs at the root of a frozen directory that should be ignored.
|
"""Files and dirs at the root of a frozen directory that should be ignored.
|
||||||
This is the same list as in the preprocess_frozen_modules script."""
|
This is the same list as in the preprocess_frozen_modules script."""
|
||||||
|
|
||||||
|
repository_urls = {}
|
||||||
|
"""Cache of repository URLs for frozen modules."""
|
||||||
|
|
||||||
def get_circuitpython_root_dir():
|
def get_circuitpython_root_dir():
|
||||||
""" The path to the root './circuitpython' directory
|
""" The path to the root './circuitpython' directory
|
||||||
"""
|
"""
|
||||||
@ -168,15 +171,38 @@ def get_settings_from_makefile(port_dir, board_name):
|
|||||||
return settings
|
return settings
|
||||||
|
|
||||||
def get_repository_url(directory):
|
def get_repository_url(directory):
|
||||||
contents = subprocess.run(
|
if directory in repository_urls:
|
||||||
["git", "remote", "get-url", "origin"],
|
return repository_urls[directory]
|
||||||
encoding="utf-8",
|
readme = None
|
||||||
errors="replace",
|
for readme_path in (
|
||||||
stdout=subprocess.PIPE,
|
os.path.join(directory, "README.rst"),
|
||||||
stderr=subprocess.PIPE,
|
os.path.join(os.path.dirname(directory), "README.rst")
|
||||||
cwd=directory
|
):
|
||||||
)
|
if os.path.exists(readme_path):
|
||||||
return contents.stdout.strip()
|
readme = readme_path
|
||||||
|
break
|
||||||
|
path = None
|
||||||
|
if readme:
|
||||||
|
with open(readme, "r") as fp:
|
||||||
|
for line in fp.readlines():
|
||||||
|
if m := re.match("\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", line):
|
||||||
|
path = m.group(1)
|
||||||
|
break
|
||||||
|
if m := re.search("<(http[^>]+)>", line):
|
||||||
|
path = m.group(1)
|
||||||
|
break
|
||||||
|
if path is None:
|
||||||
|
contents = subprocess.run(
|
||||||
|
["git", "remote", "get-url", "origin"],
|
||||||
|
encoding="utf-8",
|
||||||
|
errors="replace",
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
cwd=directory
|
||||||
|
)
|
||||||
|
path = contents.stdout.strip()
|
||||||
|
repository_urls[directory] = path
|
||||||
|
return path
|
||||||
|
|
||||||
def frozen_modules_from_dirs(frozen_mpy_dirs):
|
def frozen_modules_from_dirs(frozen_mpy_dirs):
|
||||||
"""
|
"""
|
||||||
|
2
docs/static/filter.css
vendored
2
docs/static/filter.css
vendored
@ -11,7 +11,7 @@
|
|||||||
.support-matrix-table .reference.external {
|
.support-matrix-table .reference.external {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #404050;
|
color: #404040;
|
||||||
font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", Courier, monospace;
|
font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", Courier, monospace;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
background: white;
|
background: white;
|
||||||
|
Loading…
Reference in New Issue
Block a user