[gtk-doc] mkhtml: add chunk converters for 'part' and 'reference'
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] mkhtml: add chunk converters for 'part' and 'reference'
- Date: Mon, 26 Mar 2018 07:03:12 +0000 (UTC)
commit 65c92e705f7ad5c538bbc0c160d23ffd4aafe505
Author: Stefan Sauer <ensonic users sf net>
Date: Mon Mar 26 08:03:12 2018 +0200
mkhtml: add chunk converters for 'part' and 'reference'
gtkdoc/mkhtml2.py | 72 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 47 insertions(+), 25 deletions(-)
---
diff --git a/gtkdoc/mkhtml2.py b/gtkdoc/mkhtml2.py
index b4d20d6..df1183e 100644
--- a/gtkdoc/mkhtml2.py
+++ b/gtkdoc/mkhtml2.py
@@ -831,6 +831,37 @@ def get_id(node):
return 'id-1.' + '.'.join(ix)
+def convert_chunk_with_toc(ctx, div_class, title_tag):
+ node = ctx['node']
+ result = [
+ HTML_HEADER % (node.title + ": " + node.root.title, generate_head_links(ctx)),
+ generate_basic_nav(ctx),
+ '<div class="%s">' % div_class,
+ ]
+ title = node.xml.find('title')
+ if title is not None:
+ result.append("""
+<div class="titlepage">
+<%s class="title"><a name="%s"></a>%s</%s>
+</div>""" % (
+ title_tag, get_id(node), title.text, title_tag))
+ node.xml.remove(title)
+ convert_inner(ctx, node.xml, result)
+ result.append("""<p>
+ <b>Table of Contents</b>
+</p>
+<div class="toc">
+ <dl class="toc">
+""")
+ result.extend(generate_toc(ctx, node))
+ result.append("""</dl>
+</div>
+</div>
+</body>
+</html>""")
+ return result
+
+
# docbook chunks
@@ -863,28 +894,7 @@ def convert_book(ctx):
def convert_chapter(ctx):
- node = ctx['node']
- result = [
- HTML_HEADER % (node.title + ": " + node.root.title, generate_head_links(ctx)),
- generate_basic_nav(ctx),
- '<div class="chapter">',
- ]
- title = node.xml.find('title')
- if title is not None:
- result.append('<div class="titlepage"><h2 class="title"><a name="%s"></a>%s</h2></div>' % (
- get_id(node), title.text))
- node.xml.remove(title)
- convert_inner(ctx, node.xml, result)
- result.append("""<div class="toc">
- <dl class="toc">
-""")
- result.extend(generate_toc(ctx, node))
- result.append("""</dl>
-</div>
-</div>
-</body>
-</html>""")
- return result
+ return convert_chunk_with_toc(ctx, 'chapter', 'h2')
def convert_index(ctx):
@@ -909,17 +919,23 @@ def convert_index(ctx):
return result
+def convert_part(ctx):
+ return convert_chunk_with_toc(ctx, 'part', 'h1')
+
+
def convert_preface(ctx):
node = ctx['node']
result = [
HTML_HEADER % (node.title + ": " + node.root.title, generate_head_links(ctx)),
generate_basic_nav(ctx),
- '<div class="preface">',
+ '<div class="preface">'
]
title = node.xml.find('title')
if title is not None:
- result.append('<div class="titlepage"><h2 class="title"><a name="%s"></a>%s</h2></div>' % (
- get_id(node), title.text))
+ result.append("""
+<div class="titlepage">
+<h2 class="title"><a name="%s"></a>%s</h2>
+</div>""" % (get_id(node), title.text))
node.xml.remove(title)
convert_inner(ctx, node.xml, result)
result.append("""</div>
@@ -928,6 +944,10 @@ def convert_preface(ctx):
return result
+def convert_reference(ctx):
+ return convert_chunk_with_toc(ctx, 'reference', 'h1')
+
+
def convert_refentry(ctx):
node = ctx['node']
node_id = get_id(node)
@@ -964,7 +984,9 @@ convert_chunks = {
'book': convert_book,
'chapter': convert_chapter,
'index': convert_index,
+ 'part': convert_part,
'preface': convert_preface,
+ 'reference': convert_reference,
'refentry': convert_refentry,
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]