changeset 261:803e7e990b4b

CMake: add brand new breadcrumb as navigation, closes #536
author David Demelier <markand@malikania.fr>
date Wed, 14 Sep 2016 19:20:09 +0200
parents 904ee87bc808
children 4c191ecfb94a
files doc/html/CMakeLists.txt doc/html/resources/metadata.yml doc/html/resources/template.html
diffstat 3 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/html/CMakeLists.txt	Wed Sep 14 13:36:06 2016 +0200
+++ b/doc/html/CMakeLists.txt	Wed Sep 14 19:20:09 2016 +0200
@@ -173,10 +173,12 @@
 if (WITH_HTML)
     foreach (file ${HTML_SOURCES})
         # 'baseurl': compute the tree from the file to this directory.
+        # 'inputbase': the canonical file name.
         get_filename_component(fulldirectory ${file} DIRECTORY)
+        get_filename_component(inputname ${file} NAME_WE)
         file(RELATIVE_PATH baseurl ${fulldirectory} ${html_SOURCE_DIR})
 
-        # 'inputname': relative to this source directory.
+        # 'inputbase': relative to this source directory.
         file(RELATIVE_PATH inputbase ${html_SOURCE_DIR} ${file})
 
         # 'outputbase': replace .md to .html as file extension.
@@ -193,10 +195,32 @@
             ${html_BINARY_DIR}/${inputbase}
         )
 
+        # Create a list of parents for the breadcrumb widget.
+        get_filename_component(parentlist ${inputbase} DIRECTORY)
+        string(REPLACE "/" ";" parentlist "${parentlist}")
+        set(parents "  -\n")
+        set(parents "${parents}    name: \"index\"\n")
+        set(parents "${parents}    path: \"${baseurl}index.html\"\n")
+
+        set(path "${baseurl}")
+        foreach (p ${parentlist})
+            set(path "${path}${p}/")
+            set(parents "${parents}  -\n")
+            set(parents "${parents}    name: \"${p}\"\n")
+            set(parents "${parents}    path: \"${path}index.html\"\n")
+        endforeach ()
+
+        configure_file(
+            ${html_SOURCE_DIR}/resources/metadata.yml
+            ${html_BINARY_DIR}/${inputbase}.yml
+        )
+
         # Create an output target to that file.
         pandoc(
             OUTPUT ${IRCCD_FAKEROOTDIR}/${WITH_DOCDIR}/${outputbase}
-            SOURCES ${html_BINARY_DIR}/${inputbase}
+            SOURCES
+				${html_BINARY_DIR}/${inputbase}.yml
+				${html_BINARY_DIR}/${inputbase}
             DEPENDS ${file}
             TEMPLATE ${html_SOURCE_DIR}/resources/template.html
             VARIABLE baseurl:${baseurl}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/html/resources/metadata.yml	Wed Sep 14 19:20:09 2016 +0200
@@ -0,0 +1,5 @@
+---
+parents:
+@parents@
+filename: "@inputname@"
+---
--- a/doc/html/resources/template.html	Wed Sep 14 13:36:06 2016 +0200
+++ b/doc/html/resources/template.html	Wed Sep 14 19:20:09 2016 +0200
@@ -85,6 +85,13 @@
     </div><!-- Side bar -->
 
     <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
+      <ol class="breadcrumb">
+$for(parents)$
+        <li><a href="$parents.path$">$parents.name$</a></li>
+$endfor$
+        <li class="active">$filename$</li>
+      </ol><!-- !breadcrumb -->
+
     <!-- Page body for JavaScript -->
 $if(js)$
     <!-- Page header, may be: event | module | function | method -->