Commit 4bd38090 by Arnaud Charlet Committed by Arnaud Charlet

conf.py, [...]: Improve support for Ada highlighting.

        * doc/share/conf.py, doc/share/latex_elements.py,
        doc/share/ada_pygments.py, doc/Makefile: Improve support for Ada
        highlighting.

From-SVN: r251890
parent 08705a15
2017-09-08 Arnaud Charlet <charlet@adacore.com> 2017-09-08 Arnaud Charlet <charlet@adacore.com>
* doc/share/conf.py, doc/share/latex_elements.py,
doc/share/ada_pygments.py, doc/Makefile: Improve support for Ada
highlighting.
2017-09-08 Arnaud Charlet <charlet@adacore.com>
* gnat_rm.texi, gnat_ugn.texi, * gnat_rm.texi, gnat_ugn.texi,
doc/gnat_ugn/the_gnat_compilation_model.rst, doc/gnat_ugn/the_gnat_compilation_model.rst,
doc/gnat_ugn/getting_started_with_gnat.rst, doc/gnat_ugn/getting_started_with_gnat.rst,
......
...@@ -47,7 +47,6 @@ clean: ...@@ -47,7 +47,6 @@ clean:
%.pdf: %.pdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/$*/pdf $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/$*/pdf
cp $(SOURCEDIR)/share/sphinx.sty $(BUILDDIR)/$*/pdf
$(MAKE) -C $(BUILDDIR)/$*/pdf all-pdf LATEXOPTS="-interaction=nonstopmode" $(MAKE) -C $(BUILDDIR)/$*/pdf all-pdf LATEXOPTS="-interaction=nonstopmode"
%.txt: %.txt:
......
"""Alternate Ada and Project Files parsers for Sphinx/Rest""" """Alternate Ada and Project Files parsers for Sphinx/Rest."""
import re import re
from pygments.lexer import RegexLexer, bygroups from pygments.lexer import RegexLexer, bygroups
...@@ -7,12 +7,12 @@ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ ...@@ -7,12 +7,12 @@ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
def get_lexer_tokens(tag_highlighting=False, project_support=False): def get_lexer_tokens(tag_highlighting=False, project_support=False):
"""Return the tokens needed for RegexLexer """Return the tokens needed for RegexLexer.
:param tag_highlighting: if True we support tag highlighting. See :param tag_highlighting: if True we support tag highlighting. See
AdaLexerWithTags documentation AdaLexerWithTags documentation
:type tag_highlighting: bool :type tag_highlighting: bool
:param project_support: if True support additional keywors associated :param project_support: if True support additional keywords associated
with project files. with project files.
:type project_support: bool :type project_support: bool
...@@ -21,7 +21,8 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False): ...@@ -21,7 +21,8 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False):
""" """
if project_support: if project_support:
project_pattern = r'project\s+|' project_pattern = r'project\s+|'
project_pattern2 = r'project|' project_pattern2 = \
r'aggregate|extends|external|external_as_list|library|project|'
else: else:
project_pattern = r'' project_pattern = r''
project_pattern2 = r'' project_pattern2 = r''
...@@ -46,7 +47,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False): ...@@ -46,7 +47,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False):
# Match use and with statements # Match use and with statements
# The first part of the pattern is be sure we don't match # The first part of the pattern is be sure we don't match
# for/use constructs. # for/use constructs.
(r'(\n\s*|;\s*)(with|use)(\s+[\w\.]+)', (r'(\n\s*|;\s*)(with|use)(\s+[\w\.]+\s*;)',
bygroups(Punctuation, Keyword.Reserved, Name.Namespace)), bygroups(Punctuation, Keyword.Reserved, Name.Namespace)),
# Match procedure, package and function declarations # Match procedure, package and function declarations
(r'end\s+(if|loop|record)', Keyword), (r'end\s+(if|loop|record)', Keyword),
...@@ -62,7 +63,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False): ...@@ -62,7 +63,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False):
r'Version|Value_Size|Value|Valid_Scalars|VADS_Size|Valid|Val|' r'Version|Value_Size|Value|Valid_Scalars|VADS_Size|Valid|Val|'
r'Update|Unrestricted_Access|Universal_Literal_String|' r'Update|Unrestricted_Access|Universal_Literal_String|'
r'Unconstrained_Array|Unchecked_Access|Unbiased_Rounding|' r'Unconstrained_Array|Unchecked_Access|Unbiased_Rounding|'
r'Truncation|Type_Class|To_Address|Tick|Terminated|' r'UET_Address|Truncation|Type_Class|To_Address|Tick|Terminated|'
r'Target_Name|Tag|System_Allocator_Alignment|Succ|Stub_Type|' r'Target_Name|Tag|System_Allocator_Alignment|Succ|Stub_Type|'
r'Stream_Size|Storage_Unit|Storage_Size|Storage_Pool|Small|Size|' r'Stream_Size|Storage_Unit|Storage_Size|Storage_Pool|Small|Size|'
r'Simple_Storage_Pool|Signed_Zeros|Scaling|Scale|' r'Simple_Storage_Pool|Signed_Zeros|Scaling|Scale|'
...@@ -112,7 +113,8 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False): ...@@ -112,7 +113,8 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False):
# Builtin values # Builtin values
(r'False|True', Keyword.Constant), (r'False|True', Keyword.Constant),
# Identifiers # Identifiers
(r'[\w\.]+', Name)], } (r'[\w\.]+', Name),
(r'.', Text)]}
# Insert tag highlighting before identifiers # Insert tag highlighting before identifiers
if tag_highlighting: if tag_highlighting:
...@@ -122,7 +124,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False): ...@@ -122,7 +124,7 @@ def get_lexer_tokens(tag_highlighting=False, project_support=False):
class AdaLexer(RegexLexer): class AdaLexer(RegexLexer):
"""Alternate Pygments lexer for Ada source code and project files """Alternate Pygments lexer for Ada source code and project files.
The default pygments lexer always fails causing disabling of syntax The default pygments lexer always fails causing disabling of syntax
highlighting in Sphinx. This lexer is simpler but safer. highlighting in Sphinx. This lexer is simpler but safer.
...@@ -149,7 +151,7 @@ class AdaLexer(RegexLexer): ...@@ -149,7 +151,7 @@ class AdaLexer(RegexLexer):
class TaggedAdaLexer(AdaLexer): class TaggedAdaLexer(AdaLexer):
"""Alternate Pygments lexer for Ada source code with tags """Alternate Pygments lexer for Ada source code with tags.
A tag is a string of the form:: A tag is a string of the form::
...@@ -165,7 +167,7 @@ class TaggedAdaLexer(AdaLexer): ...@@ -165,7 +167,7 @@ class TaggedAdaLexer(AdaLexer):
class GNATProjectLexer(RegexLexer): class GNATProjectLexer(RegexLexer):
"""Pygment lexer for project files """Pygment lexer for project files.
This is the same as the AdaLexer but with support of ``project`` This is the same as the AdaLexer but with support of ``project``
keyword. keyword.
......
...@@ -112,14 +112,25 @@ if os.path.isfile('favicon.ico'): ...@@ -112,14 +112,25 @@ if os.path.isfile('favicon.ico'):
html_static_path = ['_static'] html_static_path = ['_static']
latex_additional_files = ['gnat.sty']
copyright_macros = {
'date': time.strftime("%b %d, %Y"),
'edition': 'GNAT %s Edition' % 'Pro' if get_gnat_build_type() == 'PRO'
else 'GPL',
'name': u'GNU Ada',
'tool': u'GNAT',
'version': version}
latex_elements = { latex_elements = {
'preamble': latex_elements.TOC_DEPTH + 'preamble': '\\usepackage{gnat}\n' +
latex_elements.TOC_DEPTH +
latex_elements.PAGE_BLANK + latex_elements.PAGE_BLANK +
latex_elements.TOC_CMD + latex_elements.TOC_CMD +
latex_elements.LATEX_HYPHEN + latex_elements.LATEX_HYPHEN +
latex_elements.doc_settings(DOCS[doc_name]['title'], latex_elements.doc_settings(DOCS[doc_name]['title'],
get_gnat_version()), get_gnat_version()),
'tableofcontents': latex_elements.TOC} 'tableofcontents': latex_elements.TOC % copyright_macros}
latex_documents = [ latex_documents = [
(master_doc, '%s.tex' % doc_name, project, u'AdaCore', 'manual')] (master_doc, '%s.tex' % doc_name, project, u'AdaCore', 'manual')]
......
...@@ -46,11 +46,16 @@ TOC_CMD = r''' ...@@ -46,11 +46,16 @@ TOC_CMD = r'''
\makeatother \makeatother
''' '''
with open('copyright.tex', 'r') as fd:
copyright = fd.read()
TOC = r''' TOC = r'''
\cleardoublepage \cleardoublepage
%s
\cleardoublepage
\tableofcontents \tableofcontents
\cleardoublepage\pagestyle{plain} \cleardoublepage\pagestyle{plain}
''' ''' % copyright
LATEX_HYPHEN = r''' LATEX_HYPHEN = r'''
\hyphenpenalty=5000 \hyphenpenalty=5000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment