mirror of
https://github.com/triqs/dft_tools
synced 2024-12-22 20:34:38 +01:00
Merge remote-tracking branch 'app4triqs-remote/py3' into py3
This commit is contained in:
commit
09ed5c40ad
@ -10,6 +10,6 @@ WORKDIR $BUILD/$APPNAME
|
|||||||
RUN chown build .
|
RUN chown build .
|
||||||
USER build
|
USER build
|
||||||
ARG BUILD_DOC=0
|
ARG BUILD_DOC=0
|
||||||
RUN cmake $SRC/$APPNAME -DTRIQS_ROOT=${INSTALL} -DBuild_Documentation=${BUILD_DOC} && make -j2
|
RUN cmake $SRC/$APPNAME -DTRIQS_ROOT=${INSTALL} -DBuild_Documentation=${BUILD_DOC} && make -j2 || make -j1 VERBOSE=1
|
||||||
USER root
|
USER root
|
||||||
RUN make install
|
RUN make install
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# TRIQS documentation build configuration file
|
# TRIQS documentation build configuration file
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/autorun")
|
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext")
|
||||||
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/numpydoc")
|
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/numpydoc")
|
||||||
sys.path.insert(0, "@CMAKE_BINARY_DIR@/python")
|
sys.path.insert(0, "@CMAKE_BINARY_DIR@/python")
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ extensions = ['sphinx.ext.autodoc',
|
|||||||
'sphinx.ext.viewcode',
|
'sphinx.ext.viewcode',
|
||||||
'sphinx.ext.autosummary',
|
'sphinx.ext.autosummary',
|
||||||
'sphinx.ext.githubpages',
|
'sphinx.ext.githubpages',
|
||||||
|
'sphinx_autorun',
|
||||||
'matplotlib.sphinxext.plot_directive',
|
'matplotlib.sphinxext.plot_directive',
|
||||||
'autorun',
|
|
||||||
'nbsphinx',
|
'nbsphinx',
|
||||||
'IPython.sphinxext.ipython_console_highlighting',
|
'IPython.sphinxext.ipython_console_highlighting',
|
||||||
'numpydoc']
|
'numpydoc']
|
||||||
@ -46,4 +46,4 @@ html_sidebars = {'index': ['sideb.html', 'searchbox.html']}
|
|||||||
|
|
||||||
htmlhelp_basename = '@PROJECT_NAME@doc'
|
htmlhelp_basename = '@PROJECT_NAME@doc'
|
||||||
|
|
||||||
intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None), 'triqslibs': ('https://triqs.github.io/triqs/latest', None), 'triqscthyb': ('https://triqs.github.io/cthyb/latest', None)}
|
intersphinx_mapping = {'python': ('https://docs.python.org/3.8', None), 'triqslibs': ('https://triqs.github.io/triqs/latest', None), 'triqscthyb': ('https://triqs.github.io/cthyb/latest', None)}
|
||||||
|
Binary file not shown.
@ -1,104 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
sphinxcontirb.autorun
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Run the code and insert stdout after the code block.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
from subprocess import Popen,PIPE
|
|
||||||
|
|
||||||
from docutils import nodes
|
|
||||||
from docutils.parsers.rst import Directive
|
|
||||||
from docutils.parsers.rst import directives
|
|
||||||
from sphinx.errors import SphinxError
|
|
||||||
from pygments import highlight
|
|
||||||
from pygments.lexers import PythonLexer
|
|
||||||
from pygments.formatters import HtmlFormatter
|
|
||||||
|
|
||||||
class RunBlockError(SphinxError):
|
|
||||||
category = 'runblock error'
|
|
||||||
|
|
||||||
class AutoRun:
|
|
||||||
here = os.path.abspath(__file__)
|
|
||||||
pycon = os.path.join(os.path.dirname(here),'pycon.py')
|
|
||||||
config = dict(
|
|
||||||
pycon = 'python ' + pycon,
|
|
||||||
pycon_prefix_chars = 4,
|
|
||||||
pycon_show_source = False,
|
|
||||||
console = 'bash',
|
|
||||||
console_prefix_chars = 1 ,
|
|
||||||
)
|
|
||||||
@classmethod
|
|
||||||
def builder_init(cls,app):
|
|
||||||
cls.config.update(app.builder.config.autorun_languages)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RunBlock(Directive):
|
|
||||||
has_content = True
|
|
||||||
required_arguments = 1
|
|
||||||
optional_arguments = 0
|
|
||||||
final_argument_whitespace = False
|
|
||||||
option_spec = {
|
|
||||||
'linenos': directives.flag,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
config = AutoRun.config
|
|
||||||
language = self.arguments[0]
|
|
||||||
|
|
||||||
if language not in config:
|
|
||||||
raise RunBlockError('Unknown language %s' % language)
|
|
||||||
|
|
||||||
|
|
||||||
# Get configuration values for the language
|
|
||||||
args = config[language].split()
|
|
||||||
#input_encoding = config.get(language+'_input_encoding','ascii')
|
|
||||||
input_encoding = 'utf8'
|
|
||||||
output_encoding = 'utf8'
|
|
||||||
#output_encoding = config.get(language+'_output_encoding','ascii')
|
|
||||||
prefix_chars = config.get(language+'_prefix_chars',0)
|
|
||||||
show_source = config.get(language+'_show_source',True)
|
|
||||||
|
|
||||||
|
|
||||||
# Build the code text
|
|
||||||
proc = Popen(args,bufsize=1,stdin=PIPE,stdout=PIPE,stderr=PIPE)
|
|
||||||
codelines = (line[prefix_chars:] for line in self.content)
|
|
||||||
code = '\n'.join(codelines).encode(input_encoding)
|
|
||||||
|
|
||||||
# Run the code
|
|
||||||
stdout,stderr = proc.communicate(code)
|
|
||||||
|
|
||||||
# Process output
|
|
||||||
out =''
|
|
||||||
if stdout:
|
|
||||||
out += ''.join(stdout).decode(output_encoding)
|
|
||||||
if stderr:
|
|
||||||
out += ''.join(stderr).decode(output_encoding)
|
|
||||||
|
|
||||||
# Get the original code with prefixes
|
|
||||||
if show_source:
|
|
||||||
code = '\n'.join(self.content)
|
|
||||||
else:
|
|
||||||
code = ''
|
|
||||||
#code_out = u'\n\n ---Output:---\n'.join((highlight(code, PythonLexer(), HtmlFormatter()),out))
|
|
||||||
code_out = '\n\n ---Output:---\n'.join((code,out))
|
|
||||||
|
|
||||||
literal = nodes.literal_block(code_out,code_out)
|
|
||||||
#literal['language'] = language
|
|
||||||
literal['language'] = 'python'
|
|
||||||
literal['linenos'] = 'linenos' in self.options
|
|
||||||
return [literal]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
|
||||||
app.add_directive('runblock', RunBlock)
|
|
||||||
app.connect('builder-inited',AutoRun.builder_init)
|
|
||||||
app.add_config_value('autorun_languages', AutoRun.config, 'env')
|
|
||||||
|
|
||||||
# vim: set expandtab shiftwidth=4 softtabstop=4 :
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
93
doc/sphinxext/sphinx_autorun/__init__.py
Normal file
93
doc/sphinxext/sphinx_autorun/__init__.py
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
sphinxcontirb.autorun
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Run the code and insert stdout after the code block.
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
from subprocess import PIPE, Popen
|
||||||
|
|
||||||
|
from docutils import nodes
|
||||||
|
from docutils.parsers.rst import Directive, directives
|
||||||
|
from sphinx.errors import SphinxError
|
||||||
|
|
||||||
|
from sphinx_autorun import version
|
||||||
|
|
||||||
|
__version__ = version.version
|
||||||
|
|
||||||
|
|
||||||
|
class RunBlockError(SphinxError):
|
||||||
|
category = 'runblock error'
|
||||||
|
|
||||||
|
|
||||||
|
class AutoRun(object):
|
||||||
|
here = os.path.abspath(__file__)
|
||||||
|
pycon = os.path.join(os.path.dirname(here), 'pycon.py')
|
||||||
|
config = {
|
||||||
|
'pycon': 'python ' + pycon,
|
||||||
|
'pycon_prefix_chars': 4,
|
||||||
|
'pycon_show_source': False,
|
||||||
|
'console': 'bash',
|
||||||
|
'console_prefix_chars': 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def builder_init(cls, app):
|
||||||
|
cls.config.update(app.builder.config.autorun_languages)
|
||||||
|
|
||||||
|
|
||||||
|
class RunBlock(Directive):
|
||||||
|
has_content = True
|
||||||
|
required_arguments = 1
|
||||||
|
optional_arguments = 0
|
||||||
|
final_argument_whitespace = False
|
||||||
|
option_spec = {
|
||||||
|
'linenos': directives.flag,
|
||||||
|
}
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
config = AutoRun.config
|
||||||
|
language = self.arguments[0]
|
||||||
|
|
||||||
|
if language not in config:
|
||||||
|
raise RunBlockError('Unknown language %s' % language)
|
||||||
|
|
||||||
|
# Get configuration values for the language
|
||||||
|
args = config[language].split()
|
||||||
|
input_encoding = config.get(language+'_input_encoding', 'utf8')
|
||||||
|
output_encoding = config.get(language+'_output_encoding', 'utf8')
|
||||||
|
prefix_chars = config.get(language+'_prefix_chars', 0)
|
||||||
|
show_source = config.get(language+'_show_source', True)
|
||||||
|
|
||||||
|
# Build the code text
|
||||||
|
proc = Popen(args, bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
|
codelines = (line[prefix_chars:] for line in self.content)
|
||||||
|
code = u'\n'.join(codelines).encode(input_encoding)
|
||||||
|
|
||||||
|
# Run the code
|
||||||
|
stdout, stderr = proc.communicate(code)
|
||||||
|
|
||||||
|
# Process output
|
||||||
|
if stdout:
|
||||||
|
out = stdout.decode(output_encoding)
|
||||||
|
if stderr:
|
||||||
|
out = stderr.decode(output_encoding)
|
||||||
|
|
||||||
|
# Get the original code with prefixes
|
||||||
|
if show_source:
|
||||||
|
code = u'\n'.join(self.content)
|
||||||
|
code_out = u'\n'.join((code, out))
|
||||||
|
else:
|
||||||
|
code_out = out
|
||||||
|
|
||||||
|
literal = nodes.literal_block(code_out, code_out)
|
||||||
|
literal['language'] = language
|
||||||
|
literal['linenos'] = 'linenos' in self.options
|
||||||
|
return [literal]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
app.add_directive('runblock', RunBlock)
|
||||||
|
app.connect('builder-inited', AutoRun.builder_init)
|
||||||
|
app.add_config_value('autorun_languages', AutoRun.config, 'env')
|
@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from code import InteractiveInterpreter
|
from code import InteractiveInterpreter
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
Print lines of input along with output.
|
Print lines of input along with output.
|
||||||
@ -12,23 +12,20 @@ def main():
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
source = next(source_lines)
|
source = next(source_lines)
|
||||||
print('>>>', source)
|
# Allow the user to ignore specific lines of output.
|
||||||
|
if not source.endswith('# ignore'):
|
||||||
|
print('>>>', source)
|
||||||
more = console.runsource(source)
|
more = console.runsource(source)
|
||||||
while more:
|
while more:
|
||||||
next_line = next(source_lines)
|
next_line = next(source_lines)
|
||||||
print('...', next_line)
|
print('...', next_line)
|
||||||
source += '\n' + next_line
|
source += '\n' + next_line
|
||||||
more = console.runsource(source)
|
more = console.runsource(source)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
if more:
|
if more:
|
||||||
print('... ')
|
print('... ')
|
||||||
more = console.runsource(source + '\n')
|
more = console.runsource(source + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
||||||
# vim: set expandtab shiftwidth=4 softtabstop=4 :
|
|
||||||
|
|
4
doc/sphinxext/sphinx_autorun/version.py
Normal file
4
doc/sphinxext/sphinx_autorun/version.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
# file generated by setuptools_scm
|
||||||
|
# don't change, don't track in version control
|
||||||
|
version = '1.1.1'
|
Loading…
Reference in New Issue
Block a user