Skip to content

Commit

Permalink
Indices formatting tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
revarbat committed May 12, 2023
1 parent eb4e035 commit 931078e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
31 changes: 24 additions & 7 deletions openscad_docsgen/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, title, subtitle, body, origin, parent=None):

def get_file_lines(self, controller, target):
sub = self.parse_links(self.subtitle, controller, target)
sub = target.escape_entities(sub) + target.mouseover_tags(self.parent.syntags, htag="abbr")
sub = target.escape_entities(sub) + target.mouseover_tags(self.parent.syntags, htag="sup", wrap="[<abbr>{}</abbr>]")
out = target.block_header(self.title, sub, escsub=False)
return out

Expand Down Expand Up @@ -383,7 +383,7 @@ def get_file_lines(self, controller, target):
for child in self.children:
if not isinstance(child, SectionBlock):
out.extend(child.get_file_lines(controller, target))
out.extend(target.header("Table of Contents", lev=target.SECTION))
out.extend(target.header("File Contents", lev=target.SECTION))
out.extend(self.get_toc_lines(controller, target, currfile=self.origin.file))
for child in self.children:
if isinstance(child, SectionBlock):
Expand Down Expand Up @@ -697,16 +697,33 @@ def get_synopsis(self, controller, target):
out = "{}{}{}".format(
" – " if self.synopsis or self.syntags else "",
target.escape_entities(sub),
target.mouseover_tags(self.syntags, htag="abbr"),
target.mouseover_tags(self.syntags, htag="sup", wrap="[<abbr>{}</abbr>]"),
)
return out

def get_funmod(self):
funmod = self.title
if funmod == "Function":
funmod = "Func"
elif funmod == "Module":
funmod = "Mod"
elif funmod == "Function&Module":
funmod = "Func/Mod"
elif funmod == "Constant":
funmod = "Const"
return funmod

def get_index_line(self, controller, target, file):
out = "{} {}{}".format(
self.get_link(target, currfile=file),
self.get_funmod(),
self.get_synopsis(controller, target),
)
return out

def get_tocfile_lines(self, controller, target, n=1, currfile=""):
out = [
"{}{}".format(
self.get_link(target, currfile=currfile),
self.get_synopsis(controller, target),
)
self.get_index_line(controller, target, currfile)
]
return out

Expand Down
21 changes: 6 additions & 15 deletions openscad_docsgen/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,10 @@ def write_topics_file(self):
out.extend(target.markdown_block([
"An index of topics, with related functions, modules, and constants."
]))
out.extend(
target.bullet_list(
"{0}: {1}".format(
target.get_link(ltr, anchor=ltr, literalize=False),
for ltr in ltrs_found:
out.append(
"{}: {}".format(
target.bold(ltr),
", ".join(
target.get_link(
target.escape_entities(topic),
Expand All @@ -797,12 +797,9 @@ def write_topics_file(self):
for topic in sorted(index_by_letter[ltr].keys())
)
)
for ltr in ltrs_found
)
)
for ltr in ltrs_found:
topics = sorted(index_by_letter[ltr].keys())
out.extend(target.header(ltr, lev=target.SUBSECTION))
for topic in topics:
itemlist = index_by_letter[ltr][topic]
out.extend(target.header(topic, lev=target.ITEM))
Expand All @@ -811,10 +808,7 @@ def write_topics_file(self):
for name, item in sorted_items:
out.extend(
target.bullet_list_item(
"{}{}".format(
item.get_link(target, label=name, currfile=self.TOPICFILE),
item.get_synopsis(self, target),
)
item.get_index_line(self, target, self.TOPICFILE)
)
)
out.extend(target.bullet_list_end())
Expand Down Expand Up @@ -863,10 +857,7 @@ def write_index_file(self):
]))
for ltr in ltrs_found:
items = [
"{}{}".format(
item.get_link(target, label=name, currfile=self.INDEXFILE),
item.get_synopsis(self, target),
)
item.get_index_line(self, target, self.INDEXFILE)
for name, item in index_by_letter[ltr]
]
out.extend(target.header(ltr, lev=target.SUBSECTION))
Expand Down
16 changes: 11 additions & 5 deletions openscad_docsgen/target_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,21 @@ def paragraph(self, lines=[]):
lines.append("")
return lines

def mouseover_tags(self, tags, file=None, htag="sup"):
def mouseover_tags(self, tags, file=None, htag="sup", wrap="{}"):
if not file:
fmt = '&nbsp;\[<{3} title="{1}">{0}</{3}>\]'
fmt = ' <{htag} title="{text}">{abbr}</{htag}>'
elif '#' in file:
fmt = '&nbsp;\[<{3} title="{1}">[{0}]({2})</{3}>\]'
fmt = ' <{htag} title="{text}">[{abbr}]({link})</{htag}>'
else:
fmt = '&nbsp;\[<{3} title="{1}">[{0}]({2}#{0})</{3}>\]'
fmt = ' <{htag} title="{text}">[{abbr}]({link}#{linktag})</{htag}>'
out = "".join(
fmt.format(tag, text, file, htag)
fmt.format(
htag=htag,
abbr=wrap.format(tag),
text=text,
link=file,
linktag=self.header_link(tag)
)
for tag, text in tags.items()
)
return out
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup

VERSION = "2.0.38"
VERSION = "2.0.39"


with open('README.rst') as f:
Expand Down

0 comments on commit 931078e

Please sign in to comment.