[Notes] [Git][BuildStream/buildstream][bochecha/build-docs] doc: Build the docs without Buildstream installed



Title: GitLab

Mathieu Bridon pushed to branch bochecha/build-docs at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -143,7 +143,6 @@ docs:
    143 143
       - pip3 install sphinx-click
    
    144 144
       - pip3 install sphinx_rtd_theme
    
    145 145
       - cd dist && ./unpack.sh && cd buildstream
    
    146
    -  - pip3 install .
    
    147 146
       - make BST_FORCE_SESSION_REBUILD=1 -C doc
    
    148 147
       - cd ../..
    
    149 148
       - mv dist/buildstream/doc/build/html public
    

  • doc/Makefile
    ... ... @@ -31,6 +31,9 @@ ifneq ($(strip $(BST_FORCE_SESSION_REBUILD)),)
    31 31
     BST2HTMLOPTS = --force
    
    32 32
     endif
    
    33 33
     
    
    34
    +# Help Python find buildstream and its plugins
    
    35
    +PYTHONPATH=$(CURDIR)/..:$(CURDIR)/../buildstream/plugins
    
    36
    +
    
    34 37
     
    
    35 38
     .PHONY: all clean templates templates-clean sessions sessions-prep sessions-clean html devhelp
    
    36 39
     
    
    ... ... @@ -65,7 +68,6 @@ define plugin-doc-skeleton
    65 68
     endef
    
    66 69
     
    
    67 70
     
    
    68
    -# We set PYTHONPATH here because source/conf.py sys.modules hacks dont seem to help sphinx-build import the plugins
    
    69 71
     all: html devhelp
    
    70 72
     
    
    71 73
     clean: templates-clean sessions-clean
    
    ... ... @@ -103,7 +105,7 @@ sessions-prep:
    103 105
     #
    
    104 106
     sessions: sessions-prep
    
    105 107
     	for file in $(wildcard sessions/*.run); do		\
    
    106
    -	    $(BST2HTML) $(BST2HTMLOPTS) --description $$file;	\
    
    108
    +	    PYTHONPATH=$(PYTHONPATH) $(BST2HTML) $(BST2HTMLOPTS) --description $$file;	\
    
    107 109
     	done
    
    108 110
     
    
    109 111
     sessions-clean:
    
    ... ... @@ -114,7 +116,7 @@ sessions-clean:
    114 116
     #
    
    115 117
     html devhelp: templates sessions
    
    116 118
     	@echo "Building $@..."
    
    117
    -	PYTHONPATH=$(CURDIR)/../buildstream/plugins \
    
    119
    +	PYTHONPATH=$(PYTHONPATH) \
    
    118 120
     	    $(SPHINXBUILD) -b $@ $(ALLSPHINXOPTS) "$(BUILDDIR)/$@" \
    
    119 121
     	    $(wildcard source/*.rst) \
    
    120 122
     	    $(wildcard source/tutorial/*.rst) \
    

  • doc/bst2html.py
    ... ... @@ -37,6 +37,7 @@ import click
    37 37
     
    
    38 38
     from buildstream import _yaml
    
    39 39
     from buildstream import utils
    
    40
    +from buildstream._frontend import cli as bst_cli
    
    40 41
     from buildstream._exceptions import BstError
    
    41 42
     
    
    42 43
     
    
    ... ... @@ -175,6 +176,20 @@ def ansi2html(text, palette='solarized'):
    175 176
         return sub
    
    176 177
     
    
    177 178
     
    
    179
    +@contextmanager
    
    180
    +def capture_stdout_stderr():
    
    181
    +    from io import StringIO
    
    182
    +
    
    183
    +    capture = StringIO()
    
    184
    +    oldstdout, sys.stdout = sys.stdout, capture
    
    185
    +    oldstderr, sys.stderr = sys.stderr, capture
    
    186
    +
    
    187
    +    yield capture
    
    188
    +
    
    189
    +    sys.stdout = oldstdout
    
    190
    +    sys.stderr = oldstderr
    
    191
    +
    
    192
    +
    
    178 193
     # workdir()
    
    179 194
     #
    
    180 195
     # Sets up a new temp directory with a config file
    
    ... ... @@ -219,10 +234,15 @@ def workdir(source_cache=None):
    219 234
     def run_command(config_file, directory, command):
    
    220 235
         click.echo("Running command in directory '{}': bst {}".format(directory, command), err=True)
    
    221 236
     
    
    222
    -    argv = ['bst', '--colors', '--config', config_file] + shlex.split(command)
    
    223
    -    p = subprocess.Popen(argv, cwd=directory, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    
    224
    -    out, _ = p.communicate()
    
    225
    -    return out.decode('utf-8').strip()
    
    237
    +    args = ['--colors', '--config', config_file, '--directory', directory] + shlex.split(command)
    
    238
    +
    
    239
    +    with capture_stdout_stderr() as capture:
    
    240
    +        bst_cli.main(args=args, prog_name=bst_cli.name)
    
    241
    +
    
    242
    +        capture.flush()
    
    243
    +        out = capture.getvalue()
    
    244
    +
    
    245
    +    return out.strip()
    
    226 246
     
    
    227 247
     
    
    228 248
     # generate_html
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]