Skip to content

Commit 1a9fb96

Browse files
committed
Improve collapsible, add repo to repotoc
Use content to generate the unique ID for the collapsible. Add precision-converters-firmware to the repotoc. Check if conf repository value is set before using it as a key. Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent b9d0669 commit 1a9fb96

File tree

8 files changed

+32
-17
lines changed

8 files changed

+32
-17
lines changed

adi_doctools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .role import setup as role_setup
1010
from .lut import get_lut
1111

12-
__version__ = "0.3.22"
12+
__version__ = "0.3.23"
1313

1414
logger = logging.getLogger(__name__)
1515

adi_doctools/directive/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ def run(self):
212212

213213
node = node_div()
214214

215-
content, _ = self.collapsible(node, self.arguments[0].strip())
215+
_id = sha1("".join(self.content).encode('utf-8')).hexdigest()
216+
content, _ = self.collapsible(node, (_id, self.arguments[0].strip()))
216217
self.state.nested_parse(self.content, self.content_offset, content)
217218

218219
return [node]

adi_doctools/lut.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'name': 'System Level',
88
'branch': 'main',
99
'release_format': 'const:latest',
10-
'default_branch': 'main',
1110
'visibility': 'public',
1211
'topic': {
1312
'eval': 'Evaluation Boards',
@@ -24,31 +23,34 @@
2423
'name': 'HDL',
2524
'branch': 'main',
2625
'release_format': 'halves',
27-
'default_branch': 'main',
2826
'visibility': 'public'
2927
},
3028
'no-OS': {
3129
'doc_folder': 'doc/sphinx/source',
3230
'name': 'no-OS',
3331
'branch': 'main',
3432
'release_format': 'const:latest_commit',
35-
'default_branch': 'main',
3633
'visibility': 'public'
3734
},
3835
'pyadi-iio': {
3936
'doc_folder': 'doc',
4037
'name': 'pyadi-iio',
4138
'branch': 'main',
4239
'release_format': 'semantic',
43-
'default_branch': 'main',
40+
'visibility': 'public'
41+
},
42+
'precision-converters-firmware': {
43+
'doc_folder': 'doc/sphinx',
44+
'name': 'Precision Converters Firmware',
45+
'branch': 'main',
46+
'release_format': 'const:latest',
4447
'visibility': 'public'
4548
},
4649
'doctools': {
4750
'doc_folder': 'docs',
4851
'name': 'Doctools',
4952
'branch': 'main',
5053
'release_format': 'semantic',
51-
'default_branch': 'main',
5254
'visibility': 'public-hidden'
5355
},
5456
}

adi_doctools/role/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
5959
def datasheet():
6060
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
6161
# DEPRECATED
62-
logger.info("The datasheet role has been deprecated, use the adi role"
62+
logger.info("The datasheet role has been deprecated, use the adi role "
6363
"instead.")
6464
return [], []
6565

adi_doctools/role/interref.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,15 @@ def normalize_interref_mapping(app: Sphinx, config: Config) -> None:
587587
f = open(path.join(app.srcdir, latest_txt), 'rb') # NoQA: SIM115
588588
release = f.readline().decode()
589589
if release == "":
590-
logger.info(f"{repo} latest.txt is empty, setting release to \"{app.lut[repo]['default_branch']}\".")
591-
release = app.lut[repo]['default_branch']
590+
logger.info(f"{repo} latest.txt is empty, setting release to \"{app.lut[repo]['branch']}\".")
591+
release = app.lut[repo]['branch']
592592
except Exception as err:
593593
logger.warning(__('%r not fetchable due to %s: %s; setting release to \"%s\"'),
594-
latest_txt, err.__class__, str(err), app.lut[repo]['default_branch'])
595-
release = app.lut[repo]['default_branch']
594+
latest_txt, err.__class__, str(err), app.lut[repo]['branch'])
595+
release = app.lut[repo]['branch']
596596

597597
else:
598-
release = app.lut[repo]['default_branch']
598+
release = app.lut[repo]['branch']
599599
uri = interref_uri + f"{repo}/{release}"
600600
else:
601601
uri = interref_uri + repo

adi_doctools/theme/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def theme_config_setup(app):
14-
app.add_config_value('repository', '', 'env')
14+
app.add_config_value('repository', None, 'env')
1515
app.add_config_value('monolithic', False, 'env')
1616
app.add_config_value('doctools_export_metadata', False, 'env')
1717

@@ -75,7 +75,7 @@ def repotoc_tree(content_root, conf_vars, pagename):
7575
for item in repotoc:
7676
href = f"{content_root}{depth}{item}/{home}"
7777
attrib = {}
78-
if item.startswith(repo):
78+
if repo is not None and item.startswith(repo):
7979
if '/' in item:
8080
sub = item[item.find('/')+1:]
8181
href = f"{content_root}{sub}/{home}"
@@ -186,7 +186,8 @@ def iterate(elem):
186186
iterate(li)
187187
lvl.pop()
188188

189-
if "topic" in app.lut[app.env.config.repository]:
189+
repo = app.env.config.repository
190+
if repo in app.lut and "topic" in app.lut[repo]:
190191
conf_vars_ = (get_topic(pagename), *conf_vars[1:])
191192
filter_tree(root, conf_vars_, pagename)
192193

adi_doctools/theme/cosmic/style/collapsible.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
border-radius: .25em;
2929
margin-bottom: .5em;
3030

31+
.collapsible {
32+
margin: .25em;
33+
}
34+
3135
label {
3236
width: 100%;
3337
padding: 0.75em 1em 0.75em .75em;

adi_doctools/theme/cosmic/style/header.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ header {
5353
}
5454

5555
.repotoc-tree {
56-
padding-left: calc(40vw - 13em - 1em);
56+
padding-left: calc(40vw - 15em);
5757
border-bottom: $border-panel;
5858
background: var(--bg-color1);
5959
height: 2.5em;
6060

61+
root {
62+
padding-left: 1em;
63+
display: block;
64+
white-space: nowrap;
65+
overflow-x: auto;
66+
}
67+
6168
a {
6269
cursor: pointer;
6370
display: inline-block;

0 commit comments

Comments
 (0)