-
Notifications
You must be signed in to change notification settings - Fork 0
Hua work miscs #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hua work miscs #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -139,19 +139,13 @@ def process_docs(self, docname, opts, alias): | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self.parse_docs(docname) | ||||||||||||||||||||||||||||||
| if not self.sections: self.pglog(docname + ": empty document", self.LGWNEX) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self.DOCS['DOCNAM'] = docname | ||||||||||||||||||||||||||||||
| if docname in self.LINKS: self.LINKS.remove(docname) | ||||||||||||||||||||||||||||||
| self.DOCS['DOCLNK'] = r"({})".format('|'.join(self.LINKS)) | ||||||||||||||||||||||||||||||
| self.DOCS['DOCTIT'] = docname.upper() | ||||||||||||||||||||||||||||||
| self.change_local_directory(self.DOCS['DOCDIR'], self.LGWNEX) | ||||||||||||||||||||||||||||||
| self.pglog("Write rst document '{}' under {}".format(docname, self.DOCS['DOCDIR']), self.LOGWRN) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if op.exists(op.join(self.DOCS['DOCDIR'], "index.rst")): # write index file once | ||||||||||||||||||||||||||||||
| self.pglog("index.rst exists already, delete first if needs to be regenerated", self.LOGWRN) | ||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| self.write_index(self.sections[0]) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| self.write_index(self.sections[0]) | ||||||||||||||||||||||||||||||
| for section in self.sections: | ||||||||||||||||||||||||||||||
| self.write_section(section) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -183,7 +177,7 @@ def parse_docs(self, docname): | |||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| line = line.rstrip() # remove trailing white spaces | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ms = re.match(r'^([\d\.]+)\s+(.+)$', line) | ||||||||||||||||||||||||||||||
| ms = re.match(r'^([\d\.]+)\s+([A-Z].+)$', line) | ||||||||||||||||||||||||||||||
| if ms: # start new section | ||||||||||||||||||||||||||||||
| section = self.record_section(section, option, example, ms.group(1), ms.group(2)) | ||||||||||||||||||||||||||||||
| option = example = None | ||||||||||||||||||||||||||||||
|
|
@@ -284,15 +278,17 @@ def record_example(self, option, example, ndesc=None): | |||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
| if example: | ||||||||||||||||||||||||||||||
| lines = example['desc'].split('\n') | ||||||||||||||||||||||||||||||
| first_line = lines[0] | ||||||||||||||||||||||||||||||
| rest = '\n'.join(lines[1:]) if len(lines) > 1 else '' | ||||||||||||||||||||||||||||||
| ms = re.match(r'^(.*)\.\s*(.*)$', first_line) | ||||||||||||||||||||||||||||||
| if ms: | ||||||||||||||||||||||||||||||
| example['title'] = ms.group(1) | ||||||||||||||||||||||||||||||
| example['desc'] = (ms.group(2) + '\n' + rest) if rest else ms.group(2) | ||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| example['title'] = first_line | ||||||||||||||||||||||||||||||
| example['desc'] = rest | ||||||||||||||||||||||||||||||
| lcnt = len(lines) | ||||||||||||||||||||||||||||||
| title = lines[0].strip() | ||||||||||||||||||||||||||||||
| ol = 1 | ||||||||||||||||||||||||||||||
| if title[-1] != ':': | ||||||||||||||||||||||||||||||
| for l in range(1, lcnt): | ||||||||||||||||||||||||||||||
| line = lines[l].strip() | ||||||||||||||||||||||||||||||
| title += ' ' + line | ||||||||||||||||||||||||||||||
| ol += 1 | ||||||||||||||||||||||||||||||
| if line[-1] == ':': break | ||||||||||||||||||||||||||||||
| example['desc'] = '\n'.join(lines[ol:]) if lcnt > ol else '' | ||||||||||||||||||||||||||||||
|
Comment on lines
280
to
+290
|
||||||||||||||||||||||||||||||
| example['title'] = title | ||||||||||||||||||||||||||||||
| option['exmidxs'].append(len(self.examples)) # record example index in option | ||||||||||||||||||||||||||||||
| self.examples.append(example) # record example globally | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -487,29 +483,27 @@ def create_toc(self, csection=None): | |||||||||||||||||||||||||||||
| clevel = csection['level'] if csection else 0 | ||||||||||||||||||||||||||||||
| csecid = csection['secid'] if csection else "" | ||||||||||||||||||||||||||||||
| depth = self.TLEVEL - clevel | ||||||||||||||||||||||||||||||
| level = clevel+1 | ||||||||||||||||||||||||||||||
| preid = csecid+'.' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # nested bullet list for all sections | ||||||||||||||||||||||||||||||
| for section in self.sections: | ||||||||||||||||||||||||||||||
| secid = section['secid'] | ||||||||||||||||||||||||||||||
| level = section['level'] | ||||||||||||||||||||||||||||||
| if csecid: | ||||||||||||||||||||||||||||||
| if not secid.startswith(csecid + "."): continue | ||||||||||||||||||||||||||||||
| elif level > (clevel+1): | ||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||
| content += " section{}\n".format(secid) | ||||||||||||||||||||||||||||||
| if csecid and not secid.startswith(preid): continue | ||||||||||||||||||||||||||||||
| if section['level'] == level: content += " section{}\n".format(secid) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if not content: return "" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| content = f".. toctree::\n :maxdepth: {depth}\n :caption: Table of Contents\n{content}\n" | ||||||||||||||||||||||||||||||
| content = f".. toctree::\n :maxdepth: {depth}\n :caption: Table of Contents\n\n{content}\n" | ||||||||||||||||||||||||||||||
| # appendix A: list of examples for the parent section and its subsections | ||||||||||||||||||||||||||||||
| appendix = "" | ||||||||||||||||||||||||||||||
| idx = 1 # used as example index | ||||||||||||||||||||||||||||||
| for exm in self.examples: | ||||||||||||||||||||||||||||||
| opt = exm['opt'] | ||||||||||||||||||||||||||||||
| option = self.options[opt] | ||||||||||||||||||||||||||||||
| secid = option['secid'] | ||||||||||||||||||||||||||||||
| if not csecid or secid == csecid or secid.startswith(csecid + "."): | ||||||||||||||||||||||||||||||
| appendix += "- `A.{}. {} Option -{} (-{}) <{}_e{}>`_\n".format( | ||||||||||||||||||||||||||||||
| if not csecid or secid == csecid or secid.startswith(preid): | ||||||||||||||||||||||||||||||
| appendix += "- :ref:`A.{}. {} Option -{} (-{}) <{}_e{}>`\n".format( | ||||||||||||||||||||||||||||||
| idx, option['type'], opt, option['name'], secid, idx) | ||||||||||||||||||||||||||||||
| idx += 1 | ||||||||||||||||||||||||||||||
| if appendix: | ||||||||||||||||||||||||||||||
|
|
@@ -577,7 +571,7 @@ def create_option_name(self, opt, option): | |||||||||||||||||||||||||||||
| Emits a ``.. _<opt>:`` label followed by a title line of the form:: | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| <Type> Option -**XX** (-**longname**) [Alias(es): ...] : | ||||||||||||||||||||||||||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| The ``~`` underline is sized to match the actual title line length | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| The ``~`` underline is sized to match the actual title line length | |
| The ``^`` underline is sized to match the actual title line length |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_paragraph's docstring says it prefixes "Use Info option -FN…" lines with a .. _field: anchor, but that branch was removed from the implementation (only mode<secid> is emitted now). Please update the docstring or restore the field anchor behavior so they stay consistent.
| anchor and "Use Info option -FN…" lines with a ``.. _field:`` anchor. | |
| anchor. |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build_rst_simple_table assumes every row has ncols columns (row[c] for c in range(1, ncols)), but ncols is computed as the max row length; any shorter row will trigger an IndexError. The previous implementation padded missing cells; this function should either pad rows to ncols or use a conditional (row[c] if c < len(row) else '') when emitting cells.
| v = row[0] + "\n" | |
| if len(v) > 1 and v[0] == '-': v = v[1:] | |
| content += " * - " + v | |
| for c in range(1, ncols): | |
| v = row[c] + "\n" | |
| # Safely get first column value; use empty string if row has no cells. | |
| first_val = row[0] if len(row) > 0 else "" | |
| v = first_val + "\n" | |
| if len(v) > 1 and v[0] == '-': v = v[1:] | |
| content += " * - " + v | |
| for c in range(1, ncols): | |
| # Use empty string for missing cells in shorter rows. | |
| cell_val = row[c] if c < len(row) else "" | |
| v = cell_val + "\n" |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_synopsis no longer renders **Or** separators when a line contains " or ", but the docstring still describes that behavior. Please either reintroduce the separator rendering or update the docstring to avoid documenting functionality that isn't present.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,6 @@ | |
| A GUIDE TO __TITLE__ | ||
| ============================ | ||
|
|
||
| __TOC__ | ||
| __TOC__ | ||
|
|
||
| :ref:`Back to Top <index>` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process_docsnow always callswrite_index, overwriting any existingindex.rston every run. Previously this was guarded to avoid clobbering a pre-existing index. If the overwrite is intentional, consider logging that it is being regenerated (or adding an option/flag) to avoid accidental loss of manual edits in the output directory.