]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mdhelp: add <tvh_include> support for markdown
authorJaroslav Kysela <perex@perex.cz>
Thu, 5 May 2016 13:25:20 +0000 (15:25 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 5 May 2016 13:25:20 +0000 (15:25 +0200)
Makefile
docs/class/ipblocking.md
docs/markdown/inc/add1.md [new file with mode: 0644]
docs/markdown/inc/buttons1.md [new file with mode: 0644]
docs/markdown/inc/del1.md [new file with mode: 0644]
src/docs.c
src/webui/doc_md.c
support/doc/md_to_c.py

index 46041e8ff9f77e9da5bb1a576b478d451a6914cd..29c85b0f1c856823ee16f0d93619da0f9d2dfb69 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -545,10 +545,12 @@ MD-TO-C    = PYTHONIOENCODING=utf-8 $(PYTHON) support/doc/md_to_c.py
 SRCS-yes   += src/docs.c
 I18N-C-DOCS = src/docs_inc.c
 I18N-DOCS   = $(wildcard docs/markdown/*.md)
+I18N-DOCS  += $(wildcard docs/markdown/inc/*.md)
 I18N-DOCS  += $(wildcard docs/class/*.md)
 I18N-DOCS  += $(wildcard docs/property/*.md)
 I18N-DOCS  += $(wildcard docs/wizard/*.md)
 MD-ROOT     = $(patsubst docs/markdown/%.md,%,$(wildcard docs/markdown/*.md))
+MD-ROOT    += $(patsubst docs/markdown/inc/%.md,inc/%,$(wildcard docs/markdown/inc/*.md))
 MD-CLASS    = $(patsubst docs/class/%.md,%,$(wildcard docs/class/*.md))
 MD-PROP     = $(patsubst docs/property/%.md,%,$(wildcard docs/property/*.md))
 MD-WIZARD   = $(patsubst docs/wizard/%.md,%,$(wildcard docs/wizard/*.md))
@@ -684,12 +686,7 @@ $(BUILDDIR)/docs-timestamp: $(I18N-DOCS) support/doc/md_to_c.py
           $(MD-TO-C) --in="docs/wizard/$${i}.md" \
                      --name="tvh_doc_wizard_$${i}" >> src/docs_inc.c || exit 1; \
         done
-       @printf "\n\nconst struct tvh_doc_page tvh_doc_markdown_pages[] = {\n" >> src/docs_inc.c
-       @for i in $(MD-ROOT); do \
-          echo "  { \"$${i}\", tvh_doc_root_$${i} }," >> src/docs_inc.c || exit 1; \
-        done
-       @echo "  { NULL, NULL }," >> src/docs_inc.c || exit 1
-       @echo "};" >> src/docs_inc.c
+       @$(MD-TO-C) --pages="$(MD-ROOT)" >> src/docs_inc.c
        @touch $@
 
 src/docs_inc.c: $(BUILDDIR)/docs-timestamp
index 744b943adb3caca51eb2defe5ccd8f2357efde38..273db21384a4bc04a58fab29cb3207f5df963603 100644 (file)
@@ -5,32 +5,13 @@ are not allowed to login (use any Tvheadend service).
 
 ---
 
-###Menu Bar/Buttons
-
-The tab has the following buttons:
-
-Button                 | Function
------------------------|-------------------
-**Save**               | Save any changes made to the grid/entries.
-**Undo**               | Revert any changes made since the last save.
-**Add**                | Display the *Add IP Blocking Record* dialog.
-**Delete**             | Delete the selected entry/entries.
-**Edit**               | Edit the selected entry.
-**View Level**| Change the interface view level to show/hide more advanced options.
-**Help**               | Display this help page.
+<tvh_include>inc/buttons1</tvh_include>
 
 ---
 
-###Adding and Editing an Entry/Record
-
-To add an entry press the *[Add]* button from the menu bar. 
-
-To edit an entry highlight the desired entry within the grid, and 
-then press the *[Edit]* button from the menu bar.
+<tvh_include>inc/add1</tvh_include>
 
-!['Add Record Dialog'](docresources/accessipblockingedit.png)
-
-Note that both the *[Add]* and *[Edit]* buttons display similar dialogs.
+!['Add Entries Dialog'](docresources/accessipblockingedit.png)
 
 **Tip**: You can enter a comma-separated list of network prefixes, if you're 
 unsure as to what to enter in the *Network prefix* field take a look at 
@@ -38,12 +19,6 @@ unsure as to what to enter in the *Network prefix* field take a look at
 
 ---
 
-### Deleting an Entry.
-
-To delete an entry highlight (select) the entry from the grid, then press
-the *[Delete]* button from the menu bar.
-
-**Tip**: Rather than deleting an entry, you can disable it instead by 
-pressing the *[Edit]* button, and unticking the "Enabled" check box.
+<tvh_include>inc/del1</tvh_include>
 
 ---
diff --git a/docs/markdown/inc/add1.md b/docs/markdown/inc/add1.md
new file mode 100644 (file)
index 0000000..ed62d55
--- /dev/null
@@ -0,0 +1,8 @@
+###Adding and Editing an Entry/Record
+
+To add an entry press the *[Add]* button from the menu bar. 
+
+To edit an entry highlight the desired entry within the grid, and 
+then press the *[Edit]* button from the menu bar.
+
+Note that both the *[Add]* and *[Edit]* buttons display similar dialogs.
diff --git a/docs/markdown/inc/buttons1.md b/docs/markdown/inc/buttons1.md
new file mode 100644 (file)
index 0000000..4413507
--- /dev/null
@@ -0,0 +1,13 @@
+###Menu Bar/Buttons
+
+The tab has the following buttons:
+
+Button                 | Function
+-----------------------|-------------------
+**Save**               | Save any changes made to the grid/entries.
+**Undo**               | Revert any changes made since the last save.
+**Add**                | Display the *Add entry* dialog.
+**Delete**             | Delete the selected entry/entries.
+**Edit**               | Edit the selected entry.
+**View Level**         | Change the interface view level to show/hide more advanced options.
+**Help**               | Display this help page.
diff --git a/docs/markdown/inc/del1.md b/docs/markdown/inc/del1.md
new file mode 100644 (file)
index 0000000..65810d2
--- /dev/null
@@ -0,0 +1,7 @@
+### Deleting an Entry.
+
+To delete an entry highlight (select) the entry from the grid, then press
+the *[Delete]* button from the menu bar.
+
+**Tip**: Rather than deleting an entry, you can disable it instead by 
+pressing the *[Edit]* button, and unticking the "Enabled" check box.
index c4b71f55ef21548ef292fa1368e18601463625e6..684a9fad51d23d35d3d59bc78109c90425671d5f 100644 (file)
@@ -4,6 +4,7 @@
 #define LANGPREF     "\xff\x01"
 #define DOCINCPREF   "\xff\x02"
 #define ITEMSINCPREF "\xff\x03"
+#define MDINCLUDE    "\xff\x04"
 #define N_(s) s
 
 #include "docs_inc.c"
index 986b21fcea12f00107c6d5a0ace2d311ab499840..ae9a89bcc12c9c1adac08a75a520eff94eb238dc 100644 (file)
@@ -22,6 +22,7 @@
 #include "http.h"
 #include "docs.h"
 
+static int md_doc(htsbuf_queue_t *hq, const char **doc, const char *lang, int nl);
 static int md_class(htsbuf_queue_t *hq, const char *clazz, const char *lang,
                     int hdr, int docs, int props);
 
@@ -164,6 +165,7 @@ md_props(htsbuf_queue_t *hq, htsmsg_t *m, const char *lang, int nl)
 static void
 md_render(htsbuf_queue_t *hq, const char *doc, const char *lang)
 {
+  const struct tvh_doc_page *page;
   if (doc[0] == '\xff') {
     switch (doc[1]) {
     case 1:
@@ -175,6 +177,14 @@ md_render(htsbuf_queue_t *hq, const char *doc, const char *lang)
     case 3:
       md_class(hq, doc + 2, lang, 0, 0, 1);
       break;
+    case 4:
+      for (page = tvh_doc_markdown_pages; page->name; page++)
+        if (!strcmp(page->name, doc + 2)) {
+          if (page->strings)
+            md_doc(hq, page->strings, lang, 0);
+          break;
+        }
+      break;
     }
   } else {
     htsbuf_append_str(hq, doc);
index 4ff36663f429baba3f0df40fc470754aea8a5926..664379e982dc5557adfc1ba31f77d4c33921837c 100755 (executable)
@@ -198,6 +198,8 @@ class TVH_C_Renderer(Renderer):
     if a: return a
     a = self.extra_cmd(text, 'tvh_class_items', 'i')
     if a: return a
+    a = self.extra_cmd(text, 'tvh_include', 'I')
+    if a: return a
     fatal('Block HTML not allowed: ' + repr(text))
 
   def inline_html(self, text):
@@ -384,15 +386,17 @@ def optimize(text):
         if x: r += lang(x)
         x = ''
         n += t
-      elif type == 'd' or type == 'i':
+      elif type in ['d', 'i', 'I']:
         if n: r += nolang(n)
         if x: r += lang(x)
         n = ''
         x = ''
         if type == 'd':
           r += 'DOCINCPREF "' + t + '",\n'
-        else:
+        elif type == 'i':
           r += 'ITEMSINCPREF "' + t + '",\n'
+        else:
+          r += 'MDINCLUDE "' + t + '",\n'
       text = text[p+l+1:]
     if x: r += lang(x)
     x = ''
@@ -405,6 +409,18 @@ def optimize(text):
 #
 #
 
+def dopages(pages):
+  print("\n\nconst struct tvh_doc_page tvh_doc_markdown_pages[] = {")
+  for page in pages.split(' '):
+    if not page: continue
+    print("  { \"%s\", tvh_doc_root_%s }," % (page, page.replace('/', '_')))
+  print("  { NULL, NULL },")
+  print("};")
+
+#
+#
+#
+
 def fatal(msg):
   sys.stderr.write('FATAL: ' + msg + '\n')
   sys.exit(1)
@@ -426,12 +442,17 @@ def argv_get(what):
 
 HUMAN=argv_get('human')
 DEBUG=argv_get('debug')
+pages = argv_get('pages')
+if pages:
+  dopages(pages)
+  sys.exit(0)
 input = argv_get('in')
 if not input:
   fatal('Specify input file.')
 name = argv_get('name')
 if not name:
   fatal('Specify class name.')
+name = name.replace('/', '_')
 
 fp = utf8open(input, 'r')
 text = fp.read(1024*1024*2)