Skip to content

Commit

Permalink
fix(doc): Fix warnings when building doc (OCamlPro#1183)
Browse files Browse the repository at this point in the history
 - Add a simple lexer for the smt-lib language

 - Fix link to the license documentation
  • Loading branch information
bclement-ocp authored Jul 29, 2024
1 parent 7cb31e2 commit fb75290
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ jobs:
uses: ammaraskar/sphinx-action@master
with:
docs-folder: "docs/sphinx_docs/"
build-command: |
sphinx-build -b html -A current_version=${{ steps.version-name.outputs.target }} . _build
build-command: >
sphinx-build -W -b html
-A current_version=${{ steps.version-name.outputs.target }}
. _build
# Create and upload an artifact `sphinx_doc` that contains the sphinx
# documentation in html format.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The following terms apply to all such contributions:

In addition to agreeing to the terms of the Alt-Ergo's [License], we ask our contributors to sign the [Contributor License Agreement (CLA)].

[License]: ../About/licenses/index
[License]: ../About/license
[Contributor License Agreement (CLA)]: https://www.ocamlpro.com/files/CLA-OCamlPro-corporate.txt

## Develop with Nix
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx_docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

# Import our custom lexer
from alt_ergo_lexer import AltErgoLexer
from smt_lib_lexer import Smt2Lexer
from sphinx.highlighting import lexers
lexers['alt-ergo'] = AltErgoLexer()
lexers['smt-lib'] = Smt2Lexer()

# Use alt-ergo as the default language
highlight_language = 'alt-ergo'
Expand Down
89 changes: 89 additions & 0 deletions docs/sphinx_docs/smt_lib_lexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from pygments.lexer import RegexLexer, words
from pygments.token import *

__globals__ = [ 'Smt2Lexer' ]

class Smt2Lexer(RegexLexer):
"""
A SMT-LIB lexer.
"""
name = 'SMT-LIB'
url = 'https://smt-lib.org/'
aliases = [ 'smt2' ]
filenames = [ '*.smt2' ]
mimetypes = [ 'text/x-smt2 ']

keywords = (
# Commands
'assert', 'check-sat', 'check-sat-assuming', 'declare-const',
'declare-datatype', 'declare-datatypes', 'declare-fun',
'declare-sort', 'define-fun', 'define-fun-rec', 'define-funs-rec',
'define-sort', 'echo', 'exit', 'get-assertions', 'get-assignment',
'get-info', 'get-model', 'get-option', 'get-proof',
'get-unsat-assumptions', 'get-unsat-core', 'get-value', 'pop', 'push',
'reset', 'reset-assertions', 'set-info', 'set-logic', 'set-option',

# Term builtins
'let', 'forall', 'exists', 'match', '!', 'par', '_',
)

sorts = (
'Int', 'Bool', 'Real', 'BitVec', 'Array', 'RoundingMode',
)

builtins = (
# ArraysEx
'select', 'store',

# Bit-vectors
'concat', 'extract', 'bvnot', 'bvneg',
'bvand', 'bvor', 'bvxor', 'bvult', 'bvule', 'bvugt', 'bvuge',
'bvslt', 'bvsle', 'bvsgt', 'bvsge', 'bvadd', 'bvmul', 'bvudiv',
'bvsdiv', 'bvurem', 'bvsrem', 'bvshl', 'bvlshr', 'bvashr',
'bvnand', 'bvnor', 'bvxnor','bvsub', 'repeat', 'zero_extend',
'sign_extend', 'rotate_left', 'rotate_right',

# Core
'not', 'and', 'or', 'xor', 'distinct', 'ite',

# Ints, Reals and Reals_Ints
'div', 'mod', 'abs',
'to_real', 'to_int', 'is_int',

# Custom
'ae.round',
'ae.float16', 'ae.float32', 'ae.float64', 'ae.float128',
)

operators = (
'=>', '=', '-', '+', '*', '/', '<', '<=', '>', '>=',
)

symbol = r'(?:(?:[a-zA-Z0-9+/*=%?!.$_~&^<>@-]+)|(?:\|[^\|]+\|))'

symbol_suffix = r'(?![a-zA-Z0-9+/*=%?!.$_~&^<>@-])'

tokens = {
'root': [
(r';.*$', Comment.Single),
(r'\s+', Text),

(r'[0-9]+', Number.Integer),
(r'#x[0-9a-fA-F]+', Number.Integer.Hex),
(r'#b[0-1]+', Number.Integer.Bin),
(r'[0-9]+\.[0-9]+', Number.Float),
(r'"([^"]|"")*"', String),
(r':' + symbol, String.Symbol),

(r'true|false', Name.Constant),
(r'bv[0-9]+', Name.Constant),
(words(operators, suffix=symbol_suffix), Name.Operator),
(words(keywords, suffix=symbol_suffix), Keyword),
(words(sorts, suffix=symbol_suffix), Keyword.Type),
(words(builtins, suffix=symbol_suffix), Keyword.Builtin),

(symbol, Name),

(r'[_()]', Punctuation),
],
}

0 comments on commit fb75290

Please sign in to comment.