mirror of
https://git.rtems.org/rtems-docs/
synced 2025-05-14 09:49:53 +08:00

To use: 1. Install aspell 2. waf spell <list of files> * waf spell mydoc.rst * waf spell *.rst This uses a custom dictionary stored in common/spell/dict/. We should add all RTEMS and programming terms to this to ensure we are consistent. Amar.
102 lines
2.7 KiB
Python
102 lines
2.7 KiB
Python
import sys, os
|
|
from waflib.Build import BuildContext
|
|
|
|
def cmd_spell(ctx):
|
|
from waflib import Options
|
|
from sys import argv
|
|
from subprocess import call
|
|
|
|
Options.commands = None # stop warnings about knowing commands.
|
|
|
|
if not ctx.env.BIN_ASPELL:
|
|
ctx.fatal("'aspell' is required please add binary to your path and re-run configure.")
|
|
|
|
if len(argv) < 3:
|
|
ctx.fatal("Please supply at least one file name")
|
|
|
|
files = argv[2:]
|
|
|
|
path = ctx.path.parent.abspath()
|
|
|
|
# XXX: add error checking eg check if file exists.
|
|
for file in files:
|
|
cmd = ctx.env.BIN_ASPELL + ["-c", "--personal=%s/common/spell/dict/rtems" % path, "--extra-dicts=%s/common/spell/en_GB-ise-w_accents.multi" % path, file]
|
|
|
|
print "running:", cmd
|
|
call(cmd)
|
|
|
|
|
|
class spell(BuildContext):
|
|
__doc__ = "Check spelling. Supply a list of files or a glob (*.rst)"
|
|
cmd = 'spell'
|
|
fun = 'cmd_spell'
|
|
|
|
|
|
def cmd_configure(ctx):
|
|
ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD")
|
|
ctx.find_program("aspell", var="BIN_ASPELL", mandatory=False)
|
|
|
|
def cmd_build(ctx, conf_dir=".", source_dir="."):
|
|
srcnode = ctx.srcnode.abspath()
|
|
|
|
# Copy resources.
|
|
for dir in ["_static", "_templates"]:
|
|
files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir)
|
|
ctx.path.get_bld().make_node(dir).mkdir() # dirs
|
|
|
|
ctx(
|
|
features = "subst",
|
|
is_copy = True,
|
|
source = files,
|
|
target = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files]
|
|
)
|
|
|
|
ctx(
|
|
rule = "${BIN_SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir),
|
|
cwd = ctx.path.abspath(),
|
|
source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'),
|
|
target = ctx.path.find_or_declare('html/index.html')
|
|
)
|
|
|
|
def cmd_options_path(ctx):
|
|
ctx.add_option('--rtems-path-py', type='string', help="Path to py/ in RTEMS.")
|
|
|
|
|
|
def cmd_configure_path(ctx):
|
|
if not ctx.options.rtems_path_py:
|
|
ctx.fatal("--rtems-path-py is required")
|
|
|
|
ctx.env.RTEMS_PATH = ctx.options.rtems_path_py
|
|
|
|
cmd_configure(ctx)
|
|
|
|
|
|
CONF_FRAG = """
|
|
sys.path.append(os.path.abspath('../../common/'))
|
|
sys.path.append('%s')
|
|
templates_path = ['_templates']
|
|
html_static_path = ['_static']
|
|
"""
|
|
|
|
|
|
# XXX: fix this ugly hack. No time to waste on it.
|
|
def cmd_build_path(ctx):
|
|
def run(task):
|
|
|
|
with open("conf.py") as fp:
|
|
conf = "import sys, os\nsys.path.append(os.path.abspath('../../common/'))\n"
|
|
conf += fp.read()
|
|
|
|
task.inputs[0].abspath()
|
|
task.outputs[0].write(conf + (CONF_FRAG % ctx.env.RTEMS_PATH))
|
|
|
|
ctx(
|
|
rule = run,
|
|
source = [ctx.path.parent.find_node("common/conf.py"), ctx.path.find_node("./conf.py")],
|
|
target = ctx.path.get_bld().make_node('conf.py')
|
|
)
|
|
|
|
cmd_build(ctx, conf_dir="build", source_dir="build")
|
|
|
|
|