Browse Source

doc: add section numbering in html format

Nathalie Furmento 4 years ago
parent
commit
3fbcca5f2d
3 changed files with 45 additions and 0 deletions
  1. 1 0
      doc/doxygen/Makefile.am
  2. 43 0
      doc/doxygen/sectionNumbering.py
  3. 1 0
      doc/doxygen_dev/Makefile.am

+ 1 - 0
doc/doxygen/Makefile.am

@@ -278,6 +278,7 @@ $(DOX_TAG): $(dox_inputs)
 	@if test -f latex/main.tex ; then mv latex/main.tex latex/index.tex ; fi
 	@if test -f $(DOX_LATEX_DIR)/refman.tex ; then $(SED) -i '/\\begin{titlepage}/,$$d' $(DOX_LATEX_DIR)/refman.tex ; fi
 	@if test -f $(DOX_LATEX_DIR)/refman.tex ; then cat $(top_srcdir)/doc/doxygen/refman.tex >> $(DOX_LATEX_DIR)/refman.tex ; fi
+	$(top_srcdir)/doc/doxygen/sectionNumbering.py $(top_srcdir)/doc/doxygen/chapters/ $(DOX_HTML_DIR)
 
 $(DOX_HTML_DIR): $(DOX_TAG)
 

+ 43 - 0
doc/doxygen/sectionNumbering.py

@@ -0,0 +1,43 @@
+#!/usr/bin/python3
+
+import os
+import operator
+import sys
+
+files = {}
+for x in os.listdir(sys.argv[1]):
+    if x.endswith(".doxy"):
+        with open(sys.argv[1]+x, "r") as fin:
+            for line in fin.readlines():
+                if "\page" in line:
+                    line = line.replace("/*! \page ", "").strip()
+                    files[x] = line[0:line.index(" ")]+".html"
+
+sfiles= dict(sorted(files.items(), key=operator.itemgetter(0)))
+htmlfiles = ["index.html"]
+htmlfiles.extend(sfiles.values())
+
+htmldir=sys.argv[2]+"/"
+
+chapter=0
+for x in htmlfiles:
+    chapter+=1
+    section=0
+    with open(htmldir+x, "r") as fin:
+        with open(htmldir+x+".count.html", "w") as fout:
+            for line in fin.readlines():
+                if "<div class=\"title\">" in line:
+                    line = line.replace("<div class=\"title\">", "<div class=\"title\">"+str(chapter)+". ")
+                if "<h1>" in line:
+                    section += 1
+                    line = line.replace("<h1>", "<h1>" + str(chapter) + "." + str(section))
+                    subsection = 0
+                if "<h2>" in line:
+                    subsection += 1
+                    line = line.replace("<h2>", "<h2>" + str(chapter) + "." + str(section) + "." + str(subsection))
+                    subsubsection = 0
+                if "<h3>" in line:
+                    subsubsection += 1
+                    line = line.replace("<h3>", "<h3>" + str(chapter) + "." + str(section) + "." + str(subsection) + "." + str(subsubsection))
+                fout.write(line)
+    os.rename(htmldir+x+".count.html", htmldir+x)

+ 1 - 0
doc/doxygen_dev/Makefile.am

@@ -213,6 +213,7 @@ $(DOX_TAG): $(dox_inputs)
 	@if test -f latex/main.tex ; then mv latex/main.tex latex/index.tex ; fi
 	@if test -f $(DOX_LATEX_DIR)/refman.tex ; then $(SED) -i '/\\begin{titlepage}/,$$d' $(DOX_LATEX_DIR)/refman.tex ; fi
 	@if test -f $(DOX_LATEX_DIR)/refman.tex ; then cat $(top_srcdir)/doc/doxygen_dev/refman.tex >> $(DOX_LATEX_DIR)/refman.tex ; fi
+	$(top_srcdir)/doc/doxygen/sectionNumbering.py $(top_srcdir)/doc/doxygen_dev/chapters/ $(DOX_HTML_DIR)
 
 $(DOX_PDF): $(DOX_TAG) refman.tex
 	$(MKDIR_P) $(DOX_LATEX_DIR)