diff --git a/openscad_docsgen/blocks.py b/openscad_docsgen/blocks.py index f3681cd..e833a95 100644 --- a/openscad_docsgen/blocks.py +++ b/openscad_docsgen/blocks.py @@ -116,10 +116,10 @@ def get_markdown_body(self, controller, target): out.append(self.parse_links(line, controller, target)) return out - def get_tocfile_lines(self, target, n=1, currfile=""): + def get_tocfile_lines(self, controller, target, n=1, currfile=""): return [] - def get_toc_lines(self, target, n=1, currfile=""): + def get_toc_lines(self, controller, target, n=1, currfile=""): return [] def get_cheatsheet_lines(self, controller, target): @@ -337,7 +337,7 @@ def get_link(self, target, currfile=None, label=""): literalize=False ) - def get_tocfile_lines(self, target, n=1, currfile=""): + def get_tocfile_lines(self, controller, target, n=1, currfile=""): sections = [ sect for sect in self.children if isinstance(sect, SectionBlock) @@ -352,11 +352,11 @@ def get_tocfile_lines(self, target, n=1, currfile=""): out.extend(target.line_with_break(target.italics(note))) out.extend(target.bullet_list_start()) for n, sect in enumerate(sections): - out.extend(sect.get_tocfile_lines(target, n=n+1, currfile=currfile)) + out.extend(sect.get_tocfile_lines(controller, target, n=n+1, currfile=currfile)) out.extend(target.bullet_list_end()) return out - def get_toc_lines(self, target, n=1, currfile=""): + def get_toc_lines(self, controller, target, n=1, currfile=""): sections = [ sect for sect in self.children if isinstance(sect, SectionBlock) @@ -364,7 +364,7 @@ def get_toc_lines(self, target, n=1, currfile=""): out = [] out.extend(target.numbered_list_start()) for n, sect in enumerate(sections): - out.extend(sect.get_toc_lines(target, n=n+1, currfile=currfile)) + out.extend(sect.get_toc_lines(controller, target, n=n+1, currfile=currfile)) out.extend(target.numbered_list_end()) return out @@ -385,7 +385,7 @@ def get_file_lines(self, controller, target): 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(self.get_toc_lines(target, currfile=self.origin.file)) + out.extend(self.get_toc_lines(controller, target, currfile=self.origin.file)) for child in self.children: if isinstance(child, SectionBlock): out.extend(child.get_file_lines(controller, target)) @@ -423,7 +423,7 @@ def get_link(self, target, currfile=None, label=""): literalize=False ) - def get_tocfile_lines(self, target, n=1, currfile=""): + def get_tocfile_lines(self, controller, target, n=1, currfile=""): """ Return the markdown table of contents lines for the children in this section. This is returned as a series of bullet points. @@ -437,13 +437,13 @@ def get_tocfile_lines(self, target, n=1, currfile=""): if subsects: out.extend(target.bullet_list_start()) for child in subsects: - out.extend(target.indent_lines(child.get_tocfile_lines(target, currfile=currfile))) + out.extend(target.indent_lines(child.get_tocfile_lines(controller, target, currfile=currfile))) out.extend(target.bullet_list_end()) out.extend( target.indent_lines( target.bullet_list( flatten([ - child.get_tocfile_lines(target, currfile=currfile) + child.get_tocfile_lines(controller, target, currfile=currfile) for child in self.get_children_by_title( ["Constant","Function","Module","Function&Module"] ) @@ -453,12 +453,12 @@ def get_tocfile_lines(self, target, n=1, currfile=""): ) else: for child in self.get_children_by_title("Subsection"): - out.extend(child.get_tocfile_lines(target, currfile=currfile)) + out.extend(child.get_tocfile_lines(controller, target, currfile=currfile)) out.extend( target.indent_lines( target.bullet_list( flatten([ - child.get_tocfile_lines(target, currfile=currfile) + child.get_tocfile_lines(controller, target, currfile=currfile) for child in self.get_children_by_title( ["Constant","Function","Module","Function&Module"] ) @@ -468,7 +468,7 @@ def get_tocfile_lines(self, target, n=1, currfile=""): ) return out - def get_toc_lines(self, target, n=1, currfile=""): + def get_toc_lines(self, controller, target, n=1, currfile=""): """ Return the markdown table of contents lines for the children in this section. This is returned as a series of bullet points. @@ -479,10 +479,10 @@ def get_toc_lines(self, target, n=1, currfile=""): if subsects: lines.extend(target.numbered_list_start()) for num, child in enumerate(subsects): - lines.extend(child.get_toc_lines(target, currfile=currfile, n=num+1)) + lines.extend(child.get_toc_lines(controller, target, currfile=currfile, n=num+1)) lines.extend(target.numbered_list_end()) for child in self.get_children_by_title(["Constant","Function","Module","Function&Module"]): - lines.extend(child.get_toc_lines(target, currfile=currfile)) + lines.extend(child.get_toc_lines(controller, target, currfile=currfile)) out = [] if self.subtitle: item = self.get_link(target, currfile=currfile) @@ -547,7 +547,7 @@ def get_link(self, target, currfile=None, label=""): literalize=False ) - def get_tocfile_lines(self, target, n=1, currfile=""): + def get_tocfile_lines(self, controller, target, n=1, currfile=""): """ Return the markdown table of contents lines for the children in this subsection. This is returned as a series of bullet points. @@ -562,7 +562,7 @@ def get_tocfile_lines(self, target, n=1, currfile=""): target.indent_lines( target.bullet_list( flatten([ - child.get_tocfile_lines(target, currfile=currfile) + child.get_tocfile_lines(controller, target, currfile=currfile) for child in items ]) ) @@ -570,7 +570,7 @@ def get_tocfile_lines(self, target, n=1, currfile=""): ) return out - def get_toc_lines(self, target, n=1, currfile=""): + def get_toc_lines(self, controller, target, n=1, currfile=""): """ Return the markdown table of contents lines for the children in this subsection. This is returned as a series of bullet points. @@ -578,7 +578,7 @@ def get_toc_lines(self, target, n=1, currfile=""): """ lines = [] for child in self.get_children_by_title(["Constant","Function","Module","Function&Module"]): - lines.extend(child.get_toc_lines(target, currfile=currfile)) + lines.extend(child.get_toc_lines(controller, target, currfile=currfile)) out = [] if self.subtitle: item = self.get_link(target, currfile=currfile) @@ -693,24 +693,29 @@ def get_data(self): d["children"] = list(filter(lambda x: x["name"] not in skip_titles and not x["name"].startswith("Example"), d["children"])) return d - def get_tocfile_lines(self, target, n=1, currfile=""): + def get_synopsis(self, controller, target): + sub = self.parse_links(self.synopsis, controller, target) + out = "{}{}{}".format( + " – " if self.synopsis or self.syntags else "", + target.escape_entities(sub), + target.mouseover_tags(self.syntags), + ) + return out + + def get_tocfile_lines(self, controller, target, n=1, currfile=""): out = [ - "{}{}{}{}".format( + "{}{}".format( self.get_link(target, currfile=currfile), - " – " if self.synopsis or self.syntags else "", - target.escape_entities(self.synopsis), - target.mouseover_tags(self.syntags), + self.get_synopsis(controller, target), ) ] return out - def get_toc_lines(self, target, n=1, currfile=""): + def get_toc_lines(self, controller, target, n=1, currfile=""): out = target.bullet_list_item( - "{}{}{}{}".format( + "{}{}".format( self.get_link(target, currfile=currfile), - " – " if self.synopsis or self.syntags else "", - target.escape_entities(self.synopsis), - target.mouseover_tags(self.syntags), + self.get_synopsis(controller, target), ) ) return out diff --git a/openscad_docsgen/parser.py b/openscad_docsgen/parser.py index de51b0c..f525a9b 100644 --- a/openscad_docsgen/parser.py +++ b/openscad_docsgen/parser.py @@ -747,7 +747,7 @@ def write_toc_file(self): out.append("") for fnum, fblock in enumerate(prifiles): - out.extend(fblock.get_tocfile_lines(self.opts.target, n=fnum+1, currfile=self.TOCFILE)) + out.extend(fblock.get_tocfile_lines(self, self.opts.target, n=fnum+1, currfile=self.TOCFILE)) out = target.postprocess(out) outfile = os.path.join(target.docs_dir, self.TOCFILE) @@ -811,11 +811,9 @@ def write_topics_file(self): for name, item in sorted_items: out.extend( target.bullet_list_item( - "{}{}{}{}".format( + "{}{}".format( item.get_link(target, label=name, currfile=self.TOPICFILE), - " – " if item.synopsis or item.syntags else "", - target.escape_entities(item.synopsis), - target.mouseover_tags(item.syntags), + item.get_synopsis(self, target), ) ) ) @@ -865,11 +863,9 @@ def write_index_file(self): ])) for ltr in ltrs_found: items = [ - "{}{}{}{}".format( + "{}{}".format( item.get_link(target, label=name, currfile=self.INDEXFILE), - " – " if item.synopsis or item.syntags else "", - target.escape_entities(item.synopsis), - target.mouseover_tags(item.syntags), + item.get_synopsis(self, target), ) for name, item in index_by_letter[ltr] ] diff --git a/setup.py b/setup.py index ddb4cfb..be9001b 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup -VERSION = "2.0.36" +VERSION = "2.0.37" with open('README.rst') as f: