1# -*- coding: utf-8 -*- 2# 3# ASIS build configuration file 4 5import sys 6import os 7import time 8import re 9 10sys.path.append('.') 11 12import ada_pygments 13import latex_elements 14 15# Some configuration values for the various documentation handled by 16# this conf.py 17 18DOCS = { 19 'asis_rm': { 20 'title': u'ASIS-for-GNAT Reference Manual'}, 21 'asis_ug': { 22 'title': u'ASIS-for-GNAT User\'s Guide'}, 23 'gnatcheck_rm': { 24 'title': u'GNATcheck Reference Manual'}} 25 26# Then retrieve the source directory 27root_source_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 28texi_fsf = True # Set to False when FSF doc is switched to sphinx by default 29 30 31def get_copyright(): 32 return u'2008-%s, AdaCore' % time.strftime('%Y') 33 34 35def get_gnat_version(): 36 # Assume that version number is defined in file version_information 37 # two directory levels up, as the first line in this file 38 try: 39 with open('../../version_information') as vinfo: 40 line = (vinfo.readline()).strip() 41 return line 42 except: 43 print 'Error opening or reading version_information file' 44 sys.exit(1) 45 46# First retrieve the name of the documentation we are building 47doc_name = os.environ.get('DOC_NAME', None) 48if doc_name is None: 49 print 'DOC_NAME environment variable should be set' 50 sys.exit(1) 51 52if doc_name not in DOCS: 53 print '%s is not a valid documentation name' % doc_name 54 sys.exit(1) 55 56 57# Exclude sources that are not part of the current documentation 58exclude_patterns = [] 59for d in os.listdir(root_source_dir): 60 if d not in ('share', doc_name, doc_name + '.rst'): 61 exclude_patterns.append(d) 62 print 'ignoring %s' % d 63 64extensions = [] 65templates_path = ['_templates'] 66source_suffix = '.rst' 67master_doc = doc_name 68 69# General information about the project. 70project = DOCS[doc_name]['title'] 71 72copyright = get_copyright() 73 74version = get_gnat_version() 75release = get_gnat_version() 76 77pygments_style = 'sphinx' 78html_theme = 'sphinxdoc' 79if os.path.isfile('adacore_transparent.png'): 80 html_logo = 'adacore_transparent.png' 81if os.path.isfile('favicon.ico'): 82 html_favicon = 'favicon.ico' 83 84html_static_path = ['_static'] 85 86latex_elements = { 87 'preamble': latex_elements.TOC_DEPTH + 88 latex_elements.PAGE_BLANK + 89 latex_elements.TOC_CMD + 90 latex_elements.LATEX_HYPHEN + 91 latex_elements.doc_settings(DOCS[doc_name]['title'], 92 get_gnat_version()), 93 'tableofcontents': latex_elements.TOC} 94 95latex_documents = [ 96 (master_doc, '%s.tex' % doc_name, project, u'AdaCore', 'manual')] 97 98texinfo_documents = [ 99 (master_doc, doc_name, project, 100 u'AdaCore', doc_name, doc_name, '')] 101 102 103def setup(app): 104 app.add_lexer('ada', ada_pygments.AdaLexer()) 105 app.add_lexer('gpr', ada_pygments.GNATProjectLexer()) 106