Exemple #1
0
def setup(sphinx):
    thisdir = os.path.dirname(os.path.realpath(__file__))
    sys.path.insert(0, thisdir + '/utils')
    sphinx.add_lexer('Solidity', SolidityLexer())
    sphinx.add_lexer('Yul', YulLexer())

    sphinx.add_stylesheet('css/custom.css')
Exemple #2
0
def setup(sphinx):
    thisdir = os.path.dirname(os.path.realpath(__file__))
    sys.path.insert(0, thisdir + '/utils')
    from pygments_lexer_solidity import SolidityLexer
    sphinx.add_lexer('Solidity', SolidityLexer())

    sphinx.add_stylesheet('css/custom.css')
Exemple #3
0
    def format_tb(
        self,
        exc: Exception,
        filename: str = None,
        start: Optional[int] = None,
        stop: Optional[int] = None,
    ) -> str:
        if isinstance(exc, SyntaxError) and exc.text is not None:
            return self.format_syntaxerror(exc)

        tb = [
            i.replace("./", "") for i in traceback.format_tb(exc.__traceback__)
        ]
        if filename and not CONFIG.argv["tb"]:
            try:
                start = tb.index(next(i for i in tb if filename in i))
                stop = tb.index(next(i for i in tb[::-1] if filename in i)) + 1
            except Exception:
                pass

        tb = tb[start:stop]
        for i in range(len(tb)):
            info, code = tb[i].split("\n")[:2]
            info = info.replace(base_path, ".")
            info_lines = [x.strip(",") for x in info.strip().split(" ")]
            if "site-packages/" in info_lines[1]:
                info_lines[1] = '"' + info_lines[1].split("site-packages/")[1]
            tb[i] = (
                f"  {self('dark white')}File {self('bright magenta')}{info_lines[1]}"
                f"{self('dark white')}, line {self('bright blue')}{info_lines[3]}"
                f"{self('dark white')}, in {self('bright cyan')}{info_lines[5]}{self}"
            )
            if code:
                tb[i] += f"\n{code}"

        msg = str(exc)
        if isinstance(exc, VyperException):
            # apply syntax highlight and remove traceback on vyper exceptions
            msg = self.highlight(msg)
            if not CONFIG.argv["tb"]:
                tb.clear()

        from brownie.exceptions import CompilerError

        if isinstance(exc, CompilerError):
            # apply syntax highlighting on solc exceptions
            if exc.compiler == "solc":
                msg = self.highlight(msg, SolidityLexer())
            else:
                msg = self.highlight(msg)
            if not CONFIG.argv["tb"]:
                tb.clear()

        tb.append(f"{self('bright red')}{type(exc).__name__}{self}: {msg}")
        return "\n".join(tb)
Exemple #4
0
    def __init__(self):
        # SolidityLexer does not necessarily need to be installed
        # since its imported here and not used later.
        from pygments_lexer_solidity import SolidityLexer

        self.lexer = SolidityLexer()
Exemple #5
0
def setup(sphinx):
    from pygments_lexer_solidity import SolidityLexer

    sphinx.add_lexer("Solidity", SolidityLexer())
Exemple #6
0
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]

intersphinx_mapping = {
    "hypothesis": ("https://hypothesis.readthedocs.io/en/latest", None),
    "pytest": ("https://docs.pytest.org/en/latest/", None),
    "python": ("https://docs.python.org/3.8/", None),
    "web3py": ("https://web3py.readthedocs.io/en/stable/", None),
}

# -- Options for Solidity domain ---------------------------------------------

autodoc_lookup_path = "."

# -- Add Solidity lexer

from sphinx.highlighting import lexers
from pygments_lexer_solidity import SolidityLexer

lexers["solidity"] = SolidityLexer()
Exemple #7
0
# Read The Docs (rtd) theme options
# See https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html
html_theme_options = {
    'analytics_id': 'UA-142187300-2',
    'display_version': True,
    'collapse_navigation': False,
    'style_external_links': True,
    'titles_only': False
}

latex_elements = {
    'inputenc':
    '',
    'utf8extra':
    '',
    'preamble':
    r'''
    \usepackage{fontspec}
    \usepackage[slantfont, boldfont]{xeCJK}
    \XeTeXlinebreaklocale "zh"
    \XeTeXlinebreakskip = 0pt plus 1pt
    ''',
}

latex_engine = 'xelatex'

# solicity support for code blocks
from sphinx.highlighting import lexers
from pygments_lexer_solidity import SolidityLexer
lexers['solidity'] = SolidityLexer()
Exemple #8
0
 def highlight_code(code, linenos=False):
     return highlight(code, SolidityLexer(), HtmlFormatter(linenos=linenos))
Exemple #9
0
def _highlight(this, options, startline):
    return highlight('\n'.join(options['fn'](this)), SolidityLexer(),
                     HtmlFormatter(linenos='table', linenostart=startline))
Exemple #10
0
def setup(sphinx):
#   thisdir = os.path.dirname(os.path.realpath(__file__))
    sys.path.insert(0, os.path.abspath('./utils'))
    from pygments_lexer_solidity import SolidityLexer
    sphinx.add_lexer('Solidity', SolidityLexer())
 def highlight_code(code):
     return highlight(code, SolidityLexer(), HtmlFormatter())