Get autodoc working properly.

With a complete index, only generate needed files, etc.
develop
PeridexisErrant 2015-10-19 13:57:33 +11:00
parent a091ba4a70
commit bd5eb82554
3 changed files with 38 additions and 11 deletions

@ -0,0 +1,12 @@
######################
Complete Scripts Index
######################
This is the complete index of documentation pulled from script source files.
.. toctree::
:glob:
:maxdepth: 2
/scripts/**include-all

@ -15,6 +15,17 @@ or from the init file.
only be interrupted every 256 instructions. Use ``kill-lua force`` to interrupt
the next instruction.
Here's an index to documentation pulled from script source files:
.. toctree::
:glob:
:maxdepth: 2
/docs/3rdparty/
Here's the contents page for this document:
.. contents::
=================

@ -14,32 +14,36 @@
# serve to show the default.
import fnmatch
import io
from io import open
import os
import shlex
import sys
from os import listdir
from os.path import isfile, join, isdir
from os.path import isfile, join, isdir, relpath
#import sys
currentDir = '@CMAKE_CURRENT_SOURCE_DIR@'
def makeIncludeAll(directory, extension):
outputFile = join(directory,'include-all.rst')
#print(outputFile)
files = [ f for f in listdir(directory) if isfile(join(directory,f)) and f.endswith(extension) ]
files.sort()
out = open(outputFile, 'w')
dname = relpath(directory, relpath('..', currentDir)).replace('\\', '/')
while dname.startswith('..'):
dname = dname[3:]
TEMPLATE = '.. include:: /{}/{}\n :start-after: BEGIN_DOCS\n :end-before: END_DOCS'
out = []
for f in files:
#TODO: check if the file contains the BEGIN_DOCS string
#print(join(directory,f))
fstream = io.open(join(directory,f), 'r', encoding='utf8')
data = fstream.read().replace('\n','')
fstream.close()
with open(join(directory,f), 'r', encoding='utf8') as fstream:
data = fstream.read().replace('\n','')
if 'BEGIN_DOCS' in data:
out.write('.. include:: ' + join(directory,f) + '\n :start-after: BEGIN_DOCS\n :end-before: END_DOCS\n\n')
out.close()
out.append(TEMPLATE.format(dname, f))
if out:
# Only write the file if the index is not empty
with open(outputFile, 'w') as outfile:
outfile.write(len(dname)*'=' + '\n' + dname + '\n' + len(dname)*'=' + '\n\n')
outfile.write('\n\n'.join(out))
def makeAllIncludeAll(directory, extension):
for root, subdirs, files in os.walk(directory):