luadoc: added menu to left sidebar

Dieser Commit ist enthalten in:
Reinder Feenstra 2024-06-02 12:22:11 +02:00
Ursprung 801ff9f540
Commit 2e5784412e
3 geänderte Dateien mit 57 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -796,7 +796,7 @@ class LuaDoc:
LuaDoc._write_file(os.path.join(output_dir, LuaDoc.FILENAME_INDEX_AZ), html)
def _add_toc(self, html: str) -> str:
toc = '<div id="toc"><span class="title" href="#">' + self._get_term('contents') + '</span>'
toc = '<div class="toc toc-right"><span class="title" href="#">' + self._get_term('contents') + '</span>'
current_depth = 0
for tag, id, title in re.findall(r'<(h2|h3|dt) id="(.+?)">(.+?)</\1>', html):
@ -819,6 +819,19 @@ class LuaDoc:
return html.replace('<!--TOC-->', toc)
def _get_header(self, title: str, nav: list) -> str:
menu = ' <li><a href="' + LuaDoc.FILENAME_GLOBALS + '">' + self._get_term('globals:title') + '</a></li>' + os.linesep
for k in sorted(list(self._libs.keys()) + ['enum', 'set']):
if k == 'enum':
menu += ' <li><a href="' + LuaDoc.FILENAME_ENUM + '">' + self._get_term('enum:title') + '</a></li>' + os.linesep
elif k == 'set':
menu += ' <li><a href="' + LuaDoc.FILENAME_SET + '">' + self._get_term('set:title') + '</a></li>' + os.linesep
else:
lib = self._libs[k]
menu += ' <li><a href="' + lib['filename'] + '">' + self._get_term(lib['name']) + '</a></li>' + os.linesep
menu += ' <li><a href="' + LuaDoc.FILENAME_OBJECT + '">' + self._get_term('object:title') + '</a></li>' + os.linesep
menu += ' <li><a href="' + LuaDoc.FILENAME_EXAMPLE + '">' + self._get_term('example:title') + '</a></li>' + os.linesep
menu += ' <li><a href="' + LuaDoc.FILENAME_INDEX_AZ + '">' + self._get_term('index-az:title') + '</a></li>' + os.linesep
nav_html = ''
if len(nav) > 0:
nav_html += '<nav><ul>' + os.linesep
@ -840,12 +853,18 @@ class LuaDoc:
</head>
<body>
<div id="layout">
<div class="toc toc-left">
<span class="title">Menu</span>
<ul>
{menu:s}
</ul>
</div>
<!--TOC-->
<div id="main">
<div id="main" class="luadoc">
{nav:s}
<div class="content">
<h1>{title:s}</h1>
'''.format(language=self._language, title=title, nav=nav_html)
'''.format(language=self._language, title=title, menu=menu, nav=nav_html)
def _get_footer(self):
return ''' </div>

Datei anzeigen

@ -7,6 +7,11 @@
}
#main
{
margin-left: 16em;
}
#main.luadoc
{
margin-right: 16em;
}
@ -19,25 +24,36 @@ img.img-float-right
/** TOC **********************************************************************/
#toc
.toc
{
border-left: solid 2px #bbb;
padding-left: 1.5em;
color: #444;
padding-left: 1.5em;
padding-right: 1.5em;
position: fixed;
right: 0;
top: 1.5em;
width: 15em;
width: 14em;
}
#toc span.title
.toc.toc-right
{
border-left: solid 2px #bbb;
right: 0;
}
.toc.toc-left
{
border-right: solid 2px #bbb;
left: 0;
}
.toc span.title
{
font-size: 110%;
font-weight: bold;
display: inline-block;
}
#toc ul
.toc ul
{
margin: 1em 0;
padding: 0;
@ -45,31 +61,31 @@ img.img-float-right
font-size: 90%;
}
#toc ul:last-child
.toc ul:last-child
{
margin-bottom: 0;
}
#toc ul ul
.toc ul ul
{
margin: 0;
padding-left: 1em;
font-size: 90%;
}
#toc a
.toc a
{
color: #888;
text-decoration: none;
}
#toc a:hover
.toc a:hover
{
text-decoration: underline;
}
#toc a:hover,
#toc a.selected
.toc a:hover,
.toc a.selected
{
color: #000;
}
@ -356,9 +372,10 @@ pre[lang="lua"] code span.function
#main
{
margin-right: 0;
margin-left: 0;
}
#toc
.toc
{
display: none;
}
@ -379,14 +396,14 @@ pre[lang="lua"] code span.function
color: rgb(47, 129, 247)
}
#toc
.toc
{
border-color: #555;
color: #ccc;
}
#toc a:hover,
#toc a.selected
.toc a:hover,
.toc a.selected
{
color: #fff;
}

Datei anzeigen

@ -86,7 +86,7 @@ class HTMLSinglePageBuilder(HTMLBuilder):
</head>
<body>
<div id="layout">
<div id="toc">
<div id="toc" class="toc toc-left">
<span class="title" href="#">Index</span>
<ul>
'''