Generate simple examples for the docs

This commit is contained in:
Lonami Exo
2018-10-16 09:29:48 +02:00
parent 8f04ec820f
commit 477fbd8dc7
5 changed files with 168 additions and 12 deletions

View File

@@ -95,11 +95,16 @@ class DocsWriter:
raise RuntimeError('No menu had been started in the first place.')
self.write('</ul>')
def write_title(self, title, level=1):
def write_title(self, title, level=1, id=None):
"""Writes a title header in the document body,
with an optional depth level
"""
self.write('<h{level}>{title}</h{level}>', title=title, level=level)
if id:
self.write('<h{lv} id="{id}">{title}</h{lv}>',
title=title, lv=level, id=id)
else:
self.write('<h{lv}>{title}</h{lv}>',
title=title, lv=level)
def write_code(self, tlobject):
"""Writes the code for the given 'tlobject' properly