rda-python-miscs 2.0.5__tar.gz → 2.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/PKG-INFO +1 -1
  2. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/pyproject.toml +1 -1
  3. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/pg_rst.py +99 -115
  4. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rst_templates/index.rst.temp +4 -9
  5. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rst_templates/section.rst.temp +4 -5
  6. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/PKG-INFO +1 -1
  7. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/LICENSE +0 -0
  8. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/MANIFEST.in +0 -0
  9. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/README.md +0 -0
  10. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/setup.cfg +0 -0
  11. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/__init__.py +0 -0
  12. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/bash_qsub.py +0 -0
  13. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/bashqsub.py +0 -0
  14. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/bashqsub.usg +0 -0
  15. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/gdex_ls.py +0 -0
  16. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/gdexls.py +0 -0
  17. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/gdexls.usg +0 -0
  18. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/gdexls_standalone.py +0 -0
  19. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/pg_docs.py +0 -0
  20. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/pg_wget.py +0 -0
  21. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/pgwget.py +0 -0
  22. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_cp.py +0 -0
  23. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_kill.py +0 -0
  24. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_mod.py +0 -0
  25. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_own.py +0 -0
  26. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_ps.py +0 -0
  27. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_sub.py +0 -0
  28. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rda_zip.py +0 -0
  29. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdacp.py +0 -0
  30. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdacp.usg +0 -0
  31. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdakill.py +0 -0
  32. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdakill.usg +0 -0
  33. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdals.py +0 -0
  34. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdals.usg +0 -0
  35. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdamod.py +0 -0
  36. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdamod.usg +0 -0
  37. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdaown.py +0 -0
  38. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdaown.usg +0 -0
  39. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdaps.py +0 -0
  40. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdaps.usg +0 -0
  41. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdasub.py +0 -0
  42. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdasub.usg +0 -0
  43. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdazip.py +0 -0
  44. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rdazip.usg +0 -0
  45. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/rst_templates/toc.rst.temp +0 -0
  46. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/tcsh_qsub.py +0 -0
  47. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/tcshqsub.py +0 -0
  48. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs/tcshqsub.usg +0 -0
  49. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/SOURCES.txt +0 -0
  50. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/dependency_links.txt +0 -0
  51. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/entry_points.txt +0 -0
  52. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/requires.txt +0 -0
  53. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/src/rda_python_miscs.egg-info/top_level.txt +0 -0
  54. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.7}/tests/test_miscs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_miscs"
9
- version = "2.0.5"
9
+ version = "2.0.7"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -22,7 +22,6 @@ from os import path as op
22
22
  from rda_python_common.pg_file import PgFile
23
23
  from rda_python_common.pg_util import PgUtil
24
24
 
25
-
26
25
  class PgRST(PgFile, PgUtil):
27
26
  """Convert text-based program usage documents (.usg files) into
28
27
  reStructuredText (.rst) files using RST template files.
@@ -48,7 +47,7 @@ class PgRST(PgFile, PgUtil):
48
47
  Q0 = "'"
49
48
  Q1 = "**" # RST bold open (was "<i><b>")
50
49
  Q2 = "**" # RST bold close (was "</i></b>")
51
-
50
+ TLEVEL = 3 # max section level to be rendered (1, 2, or 3)
52
51
  EMLIST = {
53
52
  'dsarch' : 1,
54
53
  'msarch' : 1,
@@ -60,7 +59,6 @@ class PgRST(PgFile, PgUtil):
60
59
  'rcm' : 1,
61
60
  'dcm' : 1,
62
61
  }
63
-
64
62
  SEARCH = "(Action|Info|Mode|Multi-Value|Single-Value)"
65
63
 
66
64
  def __init__(self):
@@ -116,7 +114,6 @@ class PgRST(PgFile, PgUtil):
116
114
  'DOCTIT' : "", # document name in upper case letters
117
115
  'DOCLNK' : None,
118
116
  }
119
-
120
117
  self.LINKS = ['dsarch', 'dsupdt', 'dsrqst', 'dscheck']
121
118
 
122
119
  #
@@ -142,19 +139,13 @@ class PgRST(PgFile, PgUtil):
142
139
 
143
140
  self.parse_docs(docname)
144
141
  if not self.sections: self.pglog(docname + ": empty document", self.LGWNEX)
145
-
146
142
  self.DOCS['DOCNAM'] = docname
147
143
  if docname in self.LINKS: self.LINKS.remove(docname)
148
144
  self.DOCS['DOCLNK'] = r"({})".format('|'.join(self.LINKS))
149
145
  self.DOCS['DOCTIT'] = docname.upper()
150
146
  self.change_local_directory(self.DOCS['DOCDIR'], self.LGWNEX)
151
147
  self.pglog("Write rst document '{}' under {}".format(docname, self.DOCS['DOCDIR']), self.LOGWRN)
152
-
153
- if op.exists("index.rst"): # write index file once
154
- self.pglog("index.rst exists already, delete first if needs to be regenerated", self.LOGWRN)
155
- else:
156
- self.write_index(self.sections[0])
157
-
148
+ self.write_index(self.sections[0])
158
149
  for section in self.sections:
159
150
  self.write_section(section)
160
151
 
@@ -164,12 +155,8 @@ class PgRST(PgFile, PgUtil):
164
155
  def parse_docs(self, docname):
165
156
  """Read *docname*.usg and populate ``sections``, ``options``, and ``examples``.
166
157
 
167
- Lines beginning with ``#`` are treated as comments and skipped. Inline
168
- trailing comments are also stripped. Angle-bracketed uppercase tokens
169
- (e.g. ``<FILENAME>``) are temporarily escaped to ``&ltFILENAME&gt``
170
- so they are not misidentified as option markers (``<:>``, ``<=>``,
171
- ``<!>``) later in processing. They are unescaped back to ``<FILENAME>``
172
- in :meth:`replace_option_link` before appearing in RST output.
158
+ Lines beginning with ``#`` are treated as comments and skipped. In-line
159
+ trailing comments are also stripped.
173
160
 
174
161
  Args:
175
162
  docname (str): Short document name used to locate ``<ORIGIN>/<docname>.usg``.
@@ -190,15 +177,7 @@ class PgRST(PgFile, PgUtil):
190
177
  else:
191
178
  line = line.rstrip() # remove trailing white spaces
192
179
 
193
- # Temporarily escape <UPPERCASE> tokens so they are not confused
194
- # with special markers like <:>, <=>, <!> used in option parsing.
195
- while True:
196
- ms = re.search(r'(<([A-Z/\-\.]+)>)', line)
197
- if ms:
198
- line = line.replace(ms.group(1), "&lt{}&gt".format(ms.group(2)))
199
- else:
200
- break
201
- ms = re.match(r'^([\d\.]+)\s+(.+)$', line)
180
+ ms = re.match(r'^([\d\.]+)\s+([A-Z].+)$', line)
202
181
  if ms: # start new section
203
182
  section = self.record_section(section, option, example, ms.group(1), ms.group(2))
204
183
  option = example = None
@@ -298,10 +277,18 @@ class PgRST(PgFile, PgUtil):
298
277
  dict | None: A new example dict when *ndesc* is given, else ``None``.
299
278
  """
300
279
  if example:
301
- ms = re.match(r'^(.*)\.\s*(.*)$', example['desc'])
302
- if ms:
303
- example['title'] = ms.group(1)
304
- example['desc'] = ms.group(2)
280
+ lines = example['desc'].split('\n')
281
+ lcnt = len(lines)
282
+ title = lines[0].strip()
283
+ ol = 1
284
+ if title[-1] != ':':
285
+ for l in range(1, lcnt):
286
+ line = lines[l].strip()
287
+ title += ' ' + line
288
+ ol += 1
289
+ if line[-1] == ':': break
290
+ example['desc'] = '\n'.join(lines[ol:]) if lcnt > ol else ''
291
+ example['title'] = title
305
292
  option['exmidxs'].append(len(self.examples)) # record example index in option
306
293
  self.examples.append(example) # record example globally
307
294
 
@@ -394,7 +381,8 @@ class PgRST(PgFile, PgUtil):
394
381
  Returns:
395
382
  dict: New example dict with keys ``opt``, ``title``, and ``desc``.
396
383
  """
397
- return {'opt' : opt, 'title' : "", 'desc' : desc.title() + "\n"}
384
+ desc = (desc[0].upper() + desc[1:]) if desc else desc
385
+ return {'opt' : opt, 'title' : "", 'desc' : desc + "\n"}
398
386
 
399
387
  #
400
388
  # write the entry file: index.rst
@@ -481,8 +469,8 @@ class PgRST(PgFile, PgUtil):
481
469
  #
482
470
  # create rst content for table of contents
483
471
  #
484
- def create_toc(self):
485
- """Build and return the RST table-of-contents string.
472
+ def create_toc(self, csection=None):
473
+ """Build and return the RST table-of-contents string of a given section.
486
474
 
487
475
  Produces a nested bullet list of section links (indented by section
488
476
  level) followed by a flat Appendix A list of all example links.
@@ -490,29 +478,36 @@ class PgRST(PgFile, PgUtil):
490
478
  Returns:
491
479
  str: RST-formatted TOC content ready for ``__TOC__`` substitution.
492
480
  """
481
+
493
482
  content = ""
483
+ clevel = csection['level'] if csection else 0
484
+ csecid = csection['secid'] if csection else ""
485
+ depth = self.TLEVEL - clevel
486
+ level = clevel+1
487
+ preid = csecid+'.'
494
488
 
495
489
  # nested bullet list for all sections
496
490
  for section in self.sections:
497
491
  secid = section['secid']
498
- indent = " " * (section['level'] - 1)
499
- content += "{}- `{}. {} <section{}.rst>`_\n".format(
500
- indent, secid, section['title'], secid)
501
-
502
- content += "\n"
492
+ if csecid and not secid.startswith(preid): continue
493
+ if section['level'] == level: content += " section{}\n".format(secid)
503
494
 
504
- # appendix A: list of examples
505
- content += "**Appendix A: List of Examples**\n\n"
495
+ if not content: return ""
506
496
 
497
+ content = f".. toctree::\n :maxdepth: {depth}\n :caption: Table of Contents\n\n{content}\n"
498
+ # appendix A: list of examples for the parent section and its subsections
499
+ appendix = ""
507
500
  idx = 1 # used as example index
508
- for example in self.examples:
509
- opt = example['opt']
501
+ for exm in self.examples:
502
+ opt = exm['opt']
510
503
  option = self.options[opt]
511
504
  secid = option['secid']
512
- content += "- `A.{}. {} Option -{} (-{}) <section{}.rst#e{}>`_\n".format(
513
- idx, option['type'], opt, option['name'], secid, idx)
505
+ if not csecid or secid == csecid or secid.startswith(preid):
506
+ appendix += "- :ref:`A.{}. {} Option -{} (-{}) <{}_e{}>`\n".format(
507
+ idx, option['type'], opt, option['name'], secid, idx)
514
508
  idx += 1
515
- content += "\n"
509
+ if appendix:
510
+ content += "**Appendix A: List of Examples**\n\n" + appendix + "\n"
516
511
 
517
512
  return content
518
513
 
@@ -537,6 +532,7 @@ class PgRST(PgFile, PgUtil):
537
532
  for opt in section['opts']:
538
533
  content += self.create_option(opt, secid)
539
534
 
535
+ content += self.create_toc(section) # add a local TOC for the section and its subsections
540
536
  return content
541
537
 
542
538
  #
@@ -575,7 +571,7 @@ class PgRST(PgFile, PgUtil):
575
571
  Emits a ``.. _<opt>:`` label followed by a title line of the form::
576
572
 
577
573
  <Type> Option -**XX** (-**longname**) [Alias(es): ...] :
578
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
574
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
579
575
 
580
576
  The ``~`` underline is sized to match the actual title line length
581
577
  (including RST bold markers).
@@ -602,7 +598,7 @@ class PgRST(PgFile, PgUtil):
602
598
 
603
599
  content = "\n.. _{}:\n\n".format(opt)
604
600
  content += title + "\n"
605
- content += "~" * len(title) + "\n\n"
601
+ content += "^" * len(title) + "\n\n"
606
602
 
607
603
  return content
608
604
 
@@ -612,7 +608,7 @@ class PgRST(PgFile, PgUtil):
612
608
  def create_example(self, exmidx, secid):
613
609
  """Build the RST content for a single example.
614
610
 
615
- Emits a ``.. _e<N>:`` anchor, a bold ``EXAMPLE N. <title>`` heading,
611
+ Emits a ``.. _secid_e<N>:`` anchor, a bold ``EXAMPLE N. <title>`` heading,
616
612
  and the example's body description.
617
613
 
618
614
  Args:
@@ -624,7 +620,7 @@ class PgRST(PgFile, PgUtil):
624
620
  """
625
621
  example = self.examples[exmidx]
626
622
  exm = exmidx + 1
627
- content = "\n.. _e{}:\n\n".format(exm)
623
+ content = "\n.. _{}_e{}:\n\n".format(secid, exm)
628
624
  content += "**EXAMPLE {}. {}**\n\n".format(exm, example['title'])
629
625
  content += self.create_description(example['desc'], secid, 2)
630
626
 
@@ -671,33 +667,27 @@ class PgRST(PgFile, PgUtil):
671
667
 
672
668
  for optary in opts:
673
669
  opt = self.get_short_option(optary[1])
670
+
674
671
  pre = optary[0]
675
672
  after = optary[2]
676
673
  secid = self.options[opt]['secid']
677
- anchor = None # RST anchor name for same-file or cross-file links (.. _NAME:)
678
- if secid == csecid:
679
- anchor = opt
680
- elif self.options[opt]['type'] == "Action":
681
- anchor = "section{}".format(secid)
682
- elif ptype == 2 and opt == "FN":
683
- anchor = "field"
684
- else:
685
- anchor = "section{}".format(secid)
686
-
687
- ms = re.search(r'-\(({}\|\w+)\)'.format(opt), line)
674
+ anchor = opt
675
+ ms = re.search(r'(-\({}\|\w+\))'.format(opt), line)
688
676
  if ms:
689
677
  if secid == csecid and ptype == 2: continue
690
678
  opt = ms.group(1)
691
- after = ')'
679
+ pre = after = ''
680
+ else:
681
+ ms = re.search(r'(-{})'.format(opt), line)
682
+ if ms:
683
+ opt = ms.group(1)
684
+ pre = pre[:-1]
692
685
 
693
686
  replace = pre + opt + after
694
- if opt == anchor:
695
- link = "{}`{}`_{}".format(pre, opt, after)
696
- else:
697
- link = "{}`{} <{}_>`_{}".format(pre, opt, anchor, after)
687
+ link = "{}:ref:`{} <{}>`{}".format(pre, opt, anchor, after)
698
688
  line = line.replace(replace, link)
699
689
 
700
- opts = re.findall(r'(^|\W){}( Options*\W|\W|$)'.format(self.SEARCH), line)
690
+ opts = re.findall(r'(^|\W){}(\s+(o|O)ptions*\W|\W|$)'.format(self.SEARCH), line)
701
691
  for optary in opts:
702
692
  opt = optary[1]
703
693
  if not self.SECIDS[opt]: continue
@@ -706,20 +696,14 @@ class PgRST(PgFile, PgUtil):
706
696
  pre = optary[0]
707
697
  after = optary[2]
708
698
  replace = pre + opt + after
709
- ms = re.search(r'(\sOptions*)\W', after)
699
+ ms = re.search(r'(\s+Options*)\W', after, re.I)
710
700
  if ms:
711
701
  opt += ms.group(1)
712
702
  after = after.replace(ms.group(1), '')
713
703
  if ptype == 2 and re.search(r'Mode Options*', opt) and dtype == 3:
714
- link = "{}`{} <mode_>`_{}".format(pre, opt, after)
704
+ link = "{}:ref:`{} <mode{}>`{}".format(pre, opt, csecid, after)
715
705
  else:
716
- link = "{}`{} <section{}_>`_{}".format(pre, opt, secid, after)
717
- line = line.replace(replace, link)
718
-
719
- ms = re.search(r'(https*://\S+)(\.|\,)', line)
720
- if ms:
721
- replace = ms.group(1)
722
- link = "`{} <{}>`_".format(replace, replace)
706
+ link = "{}:ref:`{} <section{}>`{}".format(pre, opt, secid, after)
723
707
  line = line.replace(replace, link)
724
708
 
725
709
  # Q0...Q0 is a source-document quoting convention: Q0wordQ0 marks
@@ -734,10 +718,6 @@ class PgRST(PgFile, PgUtil):
734
718
  link = self.Q1 + opt + self.Q2
735
719
  line = line.replace(replace, link)
736
720
 
737
- # Unescape <UPPERCASE> tokens that were temporarily escaped during
738
- # parsing to avoid confusion with option markers (<:>, <=>, <!>).
739
- line = line.replace('&lt', '<').replace('&gt', '>')
740
-
741
721
  return line
742
722
 
743
723
  #
@@ -778,7 +758,7 @@ class PgRST(PgFile, PgUtil):
778
758
  lines = []
779
759
  ptype = 1
780
760
  cnt = 0
781
- elif cnt == 1 and re.match(r'^\s+%s\s(-|\[|ds\d*|\d+|[A-Z]{2}\s)' % self.DOCS['DOCNAM'], line):
761
+ elif cnt == 1 and re.match(r'^\s+%s\s(-|\[|[a-z]\d{6}|[A-Z]{2}\s)' % self.DOCS['DOCNAM'], line):
782
762
  ptype = 2
783
763
  elif cnt > 0:
784
764
  content += self.create_desc_content(lines, cnt, secid, dtype, ptype)
@@ -823,7 +803,7 @@ class PgRST(PgFile, PgUtil):
823
803
 
824
804
  * ``dtype=2`` with a ``<<Content ...>>`` header line: renders the
825
805
  remaining lines as a verbatim content block.
826
- * ``dtype=3``: prefixes "Mode options that…" lines with a ``.. _mode:``
806
+ * ``dtype=3``: prefixes "Mode options that…" lines with a ``.. _mode<secid>:``
827
807
  anchor and "Use Info option -FN…" lines with a ``.. _field:`` anchor.
828
808
 
829
809
  Args:
@@ -843,30 +823,27 @@ class PgRST(PgFile, PgUtil):
843
823
  if dtype == 2:
844
824
  ms = re.match(r'^<<(Content .*)>>$', line0)
845
825
  if ms: # input files for examples
846
- content += ms.group(1) + ":\n\n"
826
+ content += ms.group(1) + ":\n\n.. code-block:: none\n\n"
847
827
  normal = 0
848
828
  for i in range(1, cnt):
849
829
  line = lines[i]
850
830
  if doreplace and line.find('<:>') > -1 and not re.match(r'^[A-Z]\w+<:>[A-Z]\w+<:>', line):
851
831
  doreplace = 0
852
832
  if doreplace:
853
- content += self.replace_option_link(line, secid, 0) + "\n"
833
+ content += ' '+self.replace_option_link(line, secid, 0) + "\n"
854
834
  else:
855
- content += line + "\n"
835
+ content += ' '+line + "\n"
856
836
  if re.match(r'^\[\w+\]$', line): doreplace = 1
857
837
  content += "\n"
858
838
  if normal: # normal paragraph
859
839
  ii = 0
860
840
  if dtype == 3:
861
841
  if re.match(r'^\s*Mode options* that ', line0):
862
- content += ".. _mode:\n\n" + self.replace_option_link(line0, secid, 0) + "\n"
863
- ii = 1
864
- elif re.match(r'^\s*Use Info option -FN ', line0):
865
- content += ".. _field:\n\n" + self.replace_option_link(line0, secid, 0) + "\n"
842
+ content += f".. _mode{secid}:\n\n" + self.replace_option_link(line0, secid, 0).strip() + "\n"
866
843
  ii = 1
867
844
  for i in range(ii, cnt):
868
845
  line = lines[i]
869
- content += self.replace_option_link(line, secid, 0) + "\n"
846
+ content += self.replace_option_link(line, secid, 0).strip() + "\n"
870
847
  content += "\n"
871
848
 
872
849
  return content
@@ -879,7 +856,6 @@ class PgRST(PgFile, PgUtil):
879
856
 
880
857
  Detects three sub-formats:
881
858
 
882
- * Lines starting with ``- `` → RST numbered list (``#.``).
883
859
  * Lines ending with ``=>`` → RST line block (``|``).
884
860
  * Lines split on `` - `` (key-value pairs) → ``.. list-table::`` directive.
885
861
  * All other lines split on 2+ spaces → RST simple table.
@@ -894,16 +870,17 @@ class PgRST(PgFile, PgUtil):
894
870
  """
895
871
  line0 = lines[0]
896
872
  ms = re.match(r'^\s+-\s+(.*)', line0)
897
- if ms: # create a numbered list
898
- content = "#. " + self.replace_option_link(ms.group(1), secid, 1) + "\n"
873
+ if ms:
874
+ content = "* " + self.replace_option_link(ms.group(1), secid, 1)
899
875
  for i in range(1, cnt):
900
876
  line = lines[i]
901
877
  ms = re.match(r'^\s+-\s+(.*)', line)
902
878
  if ms:
903
- content += "#. " + self.replace_option_link(ms.group(1), secid, 1) + "\n"
879
+ content += "\n* " + self.replace_option_link(ms.group(1), secid, 1)
904
880
  else:
905
- content += " " + self.replace_option_link(line, secid, 1) + "\n"
906
- content += "\n"
881
+
882
+ content += " " + self.replace_option_link(line, secid, 1).lstrip()
883
+ content += "\n\n"
907
884
  elif re.search(r'=>$', line0):
908
885
  line = re.sub(r'={1,}', '=', line0)
909
886
  content = "| {}\n".format(line)
@@ -937,22 +914,22 @@ class PgRST(PgFile, PgUtil):
937
914
  prev_vals[1] += " " + self.replace_option_link(line, secid, 1)
938
915
  if prev_vals:
939
916
  rows.append(tuple(prev_vals))
940
- content = self._build_rst_list_table(rows)
917
+ content = self.build_rst_list_table(rows)
941
918
  else:
942
919
  # multi-column table split on 2+ spaces
943
920
  rows = []
944
921
  for i in range(cnt):
945
- line = lines[i]
922
+ line = lines[i].strip()
946
923
  vals = re.split(r'\s{2,}', self.replace_option_link(line, secid, 1))
947
924
  rows.append(vals)
948
- content = self._build_rst_simple_table(rows) + "\n"
925
+ content = self.build_rst_simple_table(rows) + "\n"
949
926
 
950
927
  return content
951
928
 
952
929
  #
953
930
  # build a two-column rst list-table
954
931
  #
955
- def _build_rst_list_table(self, rows):
932
+ def build_rst_list_table(self, rows):
956
933
  """Render *rows* as an RST ``.. list-table::`` directive.
957
934
 
958
935
  Args:
@@ -962,9 +939,11 @@ class PgRST(PgFile, PgUtil):
962
939
  str: RST list-table directive string, or ``''`` if *rows* is empty.
963
940
  """
964
941
  if not rows: return ""
965
- content = ".. list-table::\n :widths: auto\n\n"
942
+ content = ".. list-table::\n :widths: auto\n :header-rows: 0\n\n"
966
943
  for col0, col1 in rows:
944
+ if col0[0] == '-': col0 = col0[1:]
967
945
  content += " * - {}\n".format(col0)
946
+ if col1[0] == '-': col1 = col1[1:]
968
947
  content += " - {}\n".format(col1)
969
948
  content += "\n"
970
949
  return content
@@ -972,7 +951,7 @@ class PgRST(PgFile, PgUtil):
972
951
  #
973
952
  # build a multi-column rst simple table
974
953
  #
975
- def _build_rst_simple_table(self, rows):
954
+ def build_rst_simple_table(self, rows):
976
955
  """Render *rows* as an RST simple (grid-free) table.
977
956
 
978
957
  Column widths are computed from the widest cell in each column, with a
@@ -993,11 +972,17 @@ class PgRST(PgFile, PgUtil):
993
972
  if j < ncols:
994
973
  widths[j] = max(widths[j], len(val), 1)
995
974
  sep = " ".join("=" * w for w in widths) + "\n"
996
- content = sep
975
+ # content = sep
976
+ content = ".. list-table::\n :widths: auto\n :header-rows: 1\n\n"
997
977
  for row in rows:
998
- padded = ["{:<{}}".format(row[j] if j < len(row) else "", widths[j]) for j in range(ncols)]
999
- content += " ".join(padded) + "\n"
1000
- content += sep
978
+ v = row[0] + "\n"
979
+ if len(v) > 1 and v[0] == '-': v = v[1:]
980
+ content += " * - " + v
981
+ for c in range(1, ncols):
982
+ v = row[c] + "\n"
983
+ if len(v) > 1 and v[0] == '-': v = v[1:]
984
+ content += " - " + v
985
+
1001
986
  return content
1002
987
 
1003
988
  #
@@ -1024,14 +1009,11 @@ class PgRST(PgFile, PgUtil):
1024
1009
 
1025
1010
  for i in range(cnt):
1026
1011
  line = self.replace_option_link(lines[i], secid, 2, dtype)
1027
- if re.search(r'\sor\s', line, re.I):
1028
- content += "\n**Or**\n\n"
1012
+ ms = re.match(r'^\s*{}\s+(.+)$'.format(self.DOCS['DOCNAM']), line)
1013
+ if ms:
1014
+ content += "| {}{}{} {}\n".format(self.Q1, self.DOCS['DOCNAM'], self.Q2, ms.group(1))
1029
1015
  else:
1030
- ms = re.match(r'^\s*{}\s+(.+)$'.format(self.DOCS['DOCNAM']), line)
1031
- if ms:
1032
- content += "| {}{}{} {}\n".format(self.Q1, self.DOCS['DOCNAM'], self.Q2, ms.group(1))
1033
- else:
1034
- content += "| {}\n".format(line.strip())
1016
+ content += "| "+line+"\n"
1035
1017
  content += "\n"
1036
1018
 
1037
1019
  return content
@@ -1077,11 +1059,13 @@ class PgRST(PgFile, PgUtil):
1077
1059
  title (str): Section title text to look up.
1078
1060
 
1079
1061
  Returns:
1080
- str: RST `` `title <sectionN.rst>`_ `` link, or *title* if not found.
1062
+ str: RST `` `title <sectionN>`_ `` link, or *title* if not found.
1081
1063
  """
1064
+ ltitle = title.lower()
1065
+ if ltitle == "info options": ltitle = 'information options'
1082
1066
  for section in self.sections:
1083
- if title == section['title']:
1084
- return "`{} <section{}.rst>`_".format(title, section['secid'])
1067
+ if ltitle == section['title'].lower():
1068
+ return ":ref:`{} <section{}>`".format(title, section['secid'])
1085
1069
 
1086
1070
  return title
1087
1071
 
@@ -1,11 +1,10 @@
1
1
  ################################################################################
2
2
  #
3
- # Title : index.temp
3
+ # Title : index_rst.temp
4
4
  # Author : Zaihua Ji, zji@ucar.edu
5
5
  # Date : 03/17/2026
6
6
  # Purpose : template file for help document index.rst (reStructuredText)
7
- #
8
- # Work File : $DSSHOME/lib/templates/index.temp
7
+ # Github : https://github.com/NCAR/rda-python-mics.git
9
8
  #
10
9
  ################################################################################
11
10
 
@@ -15,10 +14,6 @@
15
14
  A GUIDE TO __TITLE__
16
15
  ============================
17
16
 
18
- .. toctree::
19
- :maxdepth: 2
20
- :caption: Contents
21
-
22
- section__SECID__
17
+ __TOC__
23
18
 
24
- __TOC__
19
+ :ref:`Back to Top <index>`
@@ -1,11 +1,10 @@
1
1
  ################################################################################
2
2
  #
3
- # Title : section.temp
3
+ # Title : section_rst.temp
4
4
  # Author : Zaihua Ji, zji@ucar.edu
5
5
  # Date : 03/17/2026
6
6
  # Purpose : template file for help document section.rst (reStructuredText)
7
- #
8
- # Work File : $DSSHOME/lib/templates/section.temp
7
+ # Github : https://github.com/NCAR/rda-python-mics.git
9
8
  #
10
9
  ################################################################################
11
10
 
@@ -16,5 +15,5 @@ __SECID__ - __TITLE__
16
15
 
17
16
  __SECTION__
18
17
 
19
-
20
- :ref:`Back to Top <index>`
18
+ :ref:`Back to Top <section__SECID__>`
19
+ :ref:`Back to Table of Contents <index>`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs