Changeset a316b1f in rtems-docs for common/waf.py


Ignore:
Timestamp:
01/20/16 01:37:04 (7 years ago)
Author:
Amar Takhar <amar@…>
Branches:
4.11, 5, am, master
Children:
7c1f215
Parents:
89f2347
git-author:
Amar Takhar <amar@…> (01/20/16 01:37:04)
git-committer:
Amar Takhar <verm@…> (05/03/16 00:51:25)
Message:

Add support for singlehtml (inlined) HTML file, plus some other fixes.

  • This is still broken.
  • Rename sphinx_rtd_theme so it doesn't pickup locally installed ones
  • Add a hack to theme.css to get around inliner bug.
  • Some unrelated fixups in common/waf.py

Unfortunatly several dozen fixes got merged into this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/waf.py

    r89f2347 ra316b1f  
    22from waflib.Build import BuildContext
    33
     4sphinx_min_version = (1,3)
    45
    5 sphinx_min_version = (1,3)
    66
    77def cmd_spell(ctx):
     
    3636
    3737
    38 
    3938def check_sphinx_version(ctx, minver):
    40 #       try:
    4139        version = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD + ['--version']).split(" ")[-1:][0]
    4240        ver = tuple(map(int, version.split(".")))
    43 #       except Exception:
    44 #               ctx.fatal("Version check failed please report")
    4541
    4642        if ver < minver:
     
    4945        return ver
    5046
     47
    5148def cmd_configure(ctx):
    5249        ctx.load('tex')
    53 
    5450
    5551        if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
     
    5854        ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory=True)
    5955        ctx.find_program("aspell", var="BIN_ASPELL", mandatory=False)
    60 
     56        ctx.find_program("inliner", var="BIN_INLINER", mandatory=False)
    6157
    6258        ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version)
     
    6662
    6763
     64def doc_pdf(ctx, source_dir, conf_dir):
     65        ctx(
     66                rule    = "${BIN_SPHINX_BUILD} -b latex -c %s -j %d -d build/doctrees %s build/latex" % (conf_dir, ctx.options.jobs, source_dir),
     67                cwd             = ctx.path.abspath(),
     68                source  = ctx.path.ant_glob('**/*.rst'),
     69                target  = "latex/%s.tex" % ctx.path.name
     70        )
     71
     72        ctx.add_group()
     73
     74        ctx(
     75                features        = 'tex',
     76                cwd                     = "%s/latex/" % ctx.path.get_bld().abspath(),
     77                type            = 'pdflatex',
     78                source          = ctx.bldnode.find_or_declare("latex/%s.tex" % ctx.path.name),
     79                prompt          = 0
     80        )
     81
     82
     83def doc_singlehtml(ctx, source_dir, conf_dir):
     84        if not ctx.env.BIN_INLINER:
     85                ctx.fatal("Node inliner is required install with 'npm install -g inliner' (https://github.com/remy/inliner)")
     86
     87        ctx(
     88                rule    = "${BIN_SPHINX_BUILD} -b singlehtml -c %s -j %d -d build/doctrees %s build/singlehtml" % (conf_dir, ctx.options.jobs, source_dir),
     89                cwd             = ctx.path.abspath(),
     90                source  = ctx.path.ant_glob('**/*.rst'),
     91                target  = "singlehtml/index.html"
     92        )
     93
     94        ctx.add_group()
     95
     96        ctx(
     97                rule    = "${BIN_INLINER} ${SRC} > ${TGT}",
     98                source  = "singlehtml/index.html",
     99                target  = "singlehtml/%s.html" % ctx.path.name
     100        )
     101
     102
     103def html_resources(ctx):
     104        for dir in ["_static", "_templates"]:
     105                files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir)
     106                ctx.path.get_bld().make_node(dir).mkdir() # dirs
     107
     108                ctx(
     109                        features    = "subst",
     110                        is_copy     = True,
     111                        source      = files,
     112                        target      = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files]
     113                )
     114
    68115
    69116def cmd_build(ctx, conf_dir=".", source_dir="."):
    70117        srcnode = ctx.srcnode.abspath()
    71118
     119        if not ctx.env.PDFLATEX or not ctx.env.MAKEINDEX:
     120                ctx.fatal('The programs pdflatex and makeindex are required')
     121
     122
    72123        if ctx.options.pdf:
    73 
    74                 ctx(
    75                         rule    = "${BIN_SPHINX_BUILD} -b latex -c %s -j %d -d build/doctrees %s build/latex" % (conf_dir, ctx.options.jobs, source_dir),
    76                         cwd             = ctx.path.abspath(),
    77                         source  = ctx.path.ant_glob('**/*.rst'),
    78                         target  = "latex/%s.tex" % ctx.path.name
    79                 )
    80 
    81                 ctx.add_group()
    82 
    83                 ctx(
    84                         features        = 'tex',
    85                         cwd                     = "%s/latex/" % ctx.path.get_bld().abspath(),
    86                         type            = 'pdflatex',
    87                         source          = ctx.bldnode.find_or_declare("latex/%s.tex" % ctx.path.name),
    88                         prompt          = 0
    89                 )
    90 
     124                doc_pdf(ctx, source_dir, conf_dir)
     125        elif ctx.options.singlehtml:
     126                html_resources(ctx)
     127                doc_singlehtml(ctx, source_dir, conf_dir)
    91128        else:
    92         # Copy HTML resources.
    93                 for dir in ["_static", "_templates"]:
    94                         files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir)
    95                         ctx.path.get_bld().make_node(dir).mkdir() # dirs
    96 
    97                         ctx(
    98                                 features    = "subst",
    99                                 is_copy     = True,
    100                                 source      = files,
    101                                 target      = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files]
    102                         )
    103 
     129                html_resources(ctx)
    104130                ctx(
    105131                        rule   = "${BIN_SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir),
     
    111137def cmd_options(ctx):
    112138        ctx.add_option('--pdf', action='store_true', default=False, help="Build PDF.")
     139        ctx.add_option('--singlehtml', action='store_true', default=False, help="Build Single HTML file, requires Node Inliner")
     140
    113141
    114142def cmd_options_path(ctx):
     
    152180
    153181        cmd_build(ctx, conf_dir="build", source_dir="build")
    154 
    155 
Note: See TracChangeset for help on using the changeset viewer.