1# This file is part of the Frescobaldi project, http://www.frescobaldi.org/ 2# 3# Copyright (c) 2013 - 2014 by Wilbert Berendsen 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License 7# as published by the Free Software Foundation; either version 2 8# of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18# See http://www.gnu.org/licenses/ for more information. 19 20""" 21These functions return values for python format variables in user guide pages. 22 23Some generic functions are called by several pages, but there are also some 24special, auto-generated parts of text that are used in a specific user 25guide page. 26 27""" 28 29 30import appinfo 31 32 33def appname(): 34 return appinfo.appname 35 36def version(): 37 return appinfo.version 38 39def author(): 40 return appinfo.maintainer 41 42def manual_translated_by(): 43 # L10N: Translate this sentence and fill in your own name to have it appear in the About Dialog. 44 translator = _("Translated by Your Name.") 45 if translator != "Translated by Your Name.": 46 return translator 47 return '' 48 49def table_of_contents(): 50 """Return the body of the table of contents page.""" 51 from .util import cache, format_link 52 from simplemarkdown import html_escape 53 html = ['<ul>'] 54 seen = set() 55 def addpage(page): 56 if page not in seen: 57 seen.add(page) 58 html.append("<li>" + format_link(page) + "</li>\n") 59 children = cache.children(page) 60 if children: 61 html.append('<ul>') 62 for p in children: 63 addpage(p) 64 html.append('</ul>\n') 65 for page in cache.children('index'): 66 addpage(page) 67 html.append('</ul>\n') 68 return ''.join(html) 69 70def snippet_editor_expander(): 71 """Return the auto-generated list of docstrings of the snippet variables.""" 72 from snippet import expand 73 text = [] 74 text.append("<dl>") 75 text.extend(map("<dt><code>${0[0]}</code></dt><dd>{0[1]}</dd>".format, 76 expand.documentation(expand.Expander))) 77 text.append("</dl>") 78 return ''.join(text) 79 80