Autogenerate include-all.rst for scripts so that script documentation can be entirely encapsulated in lua files without updating anything else.

develop
expwnent 2015-09-27 02:45:11 -04:00
parent 094aceff9e
commit c15b01a79a
10 changed files with 53 additions and 11 deletions

3
.gitignore vendored

@ -71,3 +71,6 @@ tags
# Mac OS X .DS_Store files
.DS_Store
# autogenerated include-all.rst files
**include-all.rst

@ -620,17 +620,14 @@ Other Scripts
=============
These scripts are not stored in any subdirectory, and can be invoked directly.
.. include:: ../scripts/include-all.rst
adaptation
==========
View or set level of cavern adaptation for the selected unit or the whole fort.
Usage: ``adaptation <show|set> <him|all> [value]``. The ``value`` must be
between 0 and 800,000 inclusive.
add-thought
===========
Adds a thought or emotion to the selected unit. Can be used by other scripts,
or the gui invoked by running ``add-thought gui`` with a unit selected.
armoks-blessing
===============
Runs the equivalent of `scripts/rejuvenate`, `scripts/elevate-physical`,

@ -18,6 +18,35 @@ import sys
import os
import shlex
from os import listdir
from os.path import isfile, join, isdir
#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')
for f in files:
#TODO: check if the file contains the BEGIN_DOCS string
#print(join(directory,f))
fstream = open(join(directory,f), 'r', encoding='utf8')
data = fstream.read().replace('\n','')
fstream.close()
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()
def makeAllIncludeAll(directory, extension):
for root, subdirs, files in os.walk(directory):
if isdir(root):
makeIncludeAll(root, extension)
makeAllIncludeAll(currentDir + '/scripts', '.lua')
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

@ -1 +1 @@
Subproject commit 412f2b283d33a4c63a5bbcfab9c015c488ab6d5d
Subproject commit 4353c10401ced7aec89f002947d1252f30237789

@ -1 +1 @@
Subproject commit e808649108be6bc97323b54151d621c57aded51f
Subproject commit 8cf05cc89782206235f4bef1b5ef98e1bc74e266

@ -1 +1 @@
Subproject commit 491c4614fb9b83015815a5784a2ba53ac3f8430f
Subproject commit 4fbced45c1ac18dba3a53804ee625cb8a666d460

@ -1 +1 @@
Subproject commit 8cffa1266d8903b568cf48366dd6f57095e3ae97
Subproject commit ac6dae2ff06d1576873b8e508017e8043e7aa701

@ -1 +1 @@
Subproject commit a0f48ba8a8fb7e32cb57125e31f76979e3687a1d
Subproject commit 5682fc2851628d84183c42d8d2d9ba0320901fb3

@ -1 +1 @@
Subproject commit 9341dd35f83bcc2c4e41cdd4ee16060a049d374d
Subproject commit 4b6e772654df6805b66f77900a4618bbf9b54dab

@ -1,6 +1,19 @@
-- Adds emotions to creatures.
--@ module = true
--[[
BEGIN_DOCS
.. _scripts/add-thought
add-thought
===========
Adds a thought or emotion to the selected unit. Can be used by other scripts,
or the gui invoked by running ``add-thought gui`` with a unit selected.
END_DOCS
]]
local utils=require('utils')
function addEmotionToUnit(unit,thought,emotion,severity,strength,subthought)