[gtk-doc] db2md: add check for future markdown



commit c83f381d421b341118556a000b7f28bb3707d32b
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed Nov 15 20:59:07 2017 +0100

    db2md: add check for future markdown
    
    We don't support emphasis yet, but will have to if we go this way.
    Check how much it would be randomly applied.

 doc/design-2.x.txt |   15 +++++++++++++--
 tools/db2md.py     |   19 +++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/doc/design-2.x.txt b/doc/design-2.x.txt
index b015f43..abc0109 100644
--- a/doc/design-2.x.txt
+++ b/doc/design-2.x.txt
@@ -97,7 +97,12 @@ We can enable such a toolchain via the configure flavors option.
 
 These would be the steps to do this:
 1.) [in progress] write the docbook comment migation tool:
-see tools: db2md.py
+see tools: tools/db2md.py
+At the same time improve the amount of markdown we handle:
+* or _: <emphasis>
+** or __: <empahsis role="strong">
+but be careful with already existing '*' and '_' chars (check warnings in
+tools/db2md.py).
 
 2.) [unassigned] create the plumbing for the new tool chain
 Add the new makefile flavour to run gtkdoc-mkhtml2 instead. Add --flavour
@@ -130,4 +135,10 @@ pandoc -r docbook -w markdown_github -o tester-docs.md tester-docs.xml
 - if we pipe it through xmllint we convert everything.
 xmllint --noent --xinclude tester-docs.xml | pandoc -r docbook -w markdown -o tester-docs.md
 - the index.md would need to represent the structure the docbook chunker would
-  create
\ No newline at end of file
+  create
+
+gdbus-codegen:
+- add an option to generate markdown comments
+
+gstreamer plugindocs:
+- generate markdown formatted files
diff --git a/tools/db2md.py b/tools/db2md.py
index c110034..8d4ad79 100644
--- a/tools/db2md.py
+++ b/tools/db2md.py
@@ -19,7 +19,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 
-"""Migate from inline docbook markup to markdown.
+"""Migrate from inline docbook markup to markdown.
 
 The tool converts markup in comments for the given source file(s). If --dry-run
 is given it would only report that docbook tags were found with exit code 1.
@@ -74,6 +74,8 @@ def convert_block(dry_run, filename, lines, beg, end):
             logging.warning("%s:%d: missing '*' in comment?", filename, ix)
             continue
 
+        line = line[indent:]
+
         # skip |[ ... ]| and <![CDATA[ ...  ]]> blocks
         if end_skip:
             if re.search(end_skip, line):
@@ -90,6 +92,18 @@ def convert_block(dry_run, filename, lines, beg, end):
             #     end_skip = r'\]\]>'
             #     continue
 
+        # TODO: skip `...` blocks
+        # check for historic non markdown compatible chars
+        if re.search(r'\s\*\w+[\s.]', line):
+            logging.warning("%s:%d: leading '*' needs escaping: '%s'", filename, ix, line)
+        #if re.search(r'\s\w+\*[\s.]', line):
+        #    logging.warning("%s:%d: trailing '*' needs escaping: '%s'", filename, ix, line)
+        if re.search(r'\s_\w+[\s.]', line):
+            logging.warning("%s:%d: leading '_' needs escaping: '%s'", filename, ix, line)
+        #if re.search(r'\s\w+_[\s.]', line):
+        #    logging.warning("%s:%d: trailing '_' needs escaping: '%s'", filename, ix, line)
+
+        # look for docbook
         for m in re.finditer(r'<([^>]*)>', line):
             tag = m.group(1)
             tag_name = tag.split(' ')[0]
@@ -117,6 +131,7 @@ def convert_block(dry_run, filename, lines, beg, end):
             return 0
 
         if dry_run:
+            print('%s:%d:' % (filename, ix))
             print_xml(root)
         else:
             # TODO: convert_tags()
@@ -145,7 +160,7 @@ def convert_file(dry_run, filename):
         if beg == -1 and end == -1:
             if re.search(r'^\s*/\*.*\*/', line):
                 pass
-            elif re.search(r'^\s*/\*\*\s*', line):
+            elif re.search(r'^\s*/\*\*(\s|$)', line):
                 logging.debug("%s:%d: comment start", filename, ix)
                 beg = ix
         elif beg > -1 and end == -1:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]