mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add post-processing for the sphinx htmlhelp output before build
* Copies our .hhk into the build folder * Removes TOC entries that just refer to anchors - it's unnecessary and just clutters up the TOC.
This commit is contained in:
@@ -86,6 +86,11 @@ json:
|
||||
.PHONY: htmlhelp
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
# Copy handwritten index file to output, overwriting auto-generated one
|
||||
@cp renderdoc.hhk $(BUILDDIR)/htmlhelp
|
||||
# Filter out the auto-generated TOC to remove anchor links and root index.html
|
||||
@cat $(BUILDDIR)/htmlhelp/renderdoc.hhc | python remove_lines.py ".html#" | python remove_lines.py "\"index.html\"" > $(BUILDDIR)/htmlhelp/tmp
|
||||
@mv $(BUILDDIR)/htmlhelp/tmp $(BUILDDIR)/htmlhelp/renderdoc.hhc
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
+6
-1
@@ -5,7 +5,7 @@ REM Command file for Sphinx documentation
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=../Documentation
|
||||
set BUILDDIR=..\Documentation
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
@@ -117,6 +117,11 @@ if "%1" == "json" (
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
REM Copy handwritten index file to output, overwriting auto-generated one
|
||||
copy renderdoc.hhk %BUILDDIR%\htmlhelp\
|
||||
REM Filter out the auto-generated TOC to remove anchor links and root index.html
|
||||
type %BUILDDIR%\htmlhelp\renderdoc.hhc | python remove_lines.py ".html#" | python remove_lines.py "\"index.html\"" > %BUILDDIR%\htmlhelp\tmp
|
||||
move %BUILDDIR%\htmlhelp\tmp %BUILDDIR%\htmlhelp\renderdoc.hhc
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
|
||||
@@ -101,6 +101,11 @@ fi
|
||||
if [ $1 == "htmlhelp" ]; then
|
||||
$SPHINXBUILD -b htmlhelp $ALLSPHINXOPTS $BUILDDIR/htmlhelp
|
||||
if [ $? != 0 ]; then exit 1; fi
|
||||
# Copy handwritten index file to output, overwriting auto-generated one
|
||||
cp renderdoc.hhk $BUILDDIR/htmlhelp
|
||||
# Filter out the auto-generated TOC to remove anchor links and root index.html
|
||||
cat $BUILDDIR/htmlhelp/renderdoc.hhc | python remove_lines.py ".html#" | python remove_lines.py "\"index.html\"" > $BUILDDIR/htmlhelp/tmp
|
||||
mv $BUILDDIR/htmlhelp/tmp $BUILDDIR/htmlhelp/renderdoc.hhc
|
||||
echo
|
||||
echo "Build finished; now you can run HTML Help Workshop with the "
|
||||
echo ".hhp project file in $BUILDDIR/htmlhelp."
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Script taken from http://stackoverflow.com/a/17579949/4070143 by inspectorG4dget
|
||||
# to remove lines above and below certain string match.
|
||||
# Minor modifications to read and write from stdin/stdout respectively
|
||||
# and to remove some extra newlines getting added
|
||||
|
||||
import sys
|
||||
|
||||
def remLines(delim, above, below):
|
||||
buff = []
|
||||
line = sys.stdin.readline()
|
||||
while line:
|
||||
if delim in line.strip():
|
||||
buff = []
|
||||
for _ in range(below):
|
||||
sys.stdin.readline()
|
||||
else:
|
||||
if len(buff) == above:
|
||||
print(buff[0].replace('\r', '').replace('\n', ''))
|
||||
buff = buff[1:]
|
||||
buff.append(line)
|
||||
line = sys.stdin.readline()
|
||||
print(''.join(buff).strip())
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Error: no search pattern specified")
|
||||
else:
|
||||
remLines(sys.argv[1], 2, 1)
|
||||
Reference in New Issue
Block a user