Exemplo n.º 1
0
    def __init__(self, builder, *args, **kwds):
        BaseTranslator.__init__(self, *args, **kwds)
        self.builder = builder

        self.in_productionlist = 0

        # first title is the manpage title
        self.section_level = -1

        # docinfo set by man_pages config value
        self._docinfo['title'] = self.document.settings.title
        self._docinfo['subtitle'] = self.document.settings.subtitle
        if self.document.settings.authors:
            # don't set it if no author given
            self._docinfo['author'] = self.document.settings.authors
        self._docinfo['manual_section'] = self.document.settings.section

        # docinfo set by other config values
        self._docinfo['title_upper'] = self._docinfo['title'].upper()
        if builder.config.today:
            self._docinfo['date'] = builder.config.today
        else:
            self._docinfo['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'),
                                                language=builder.config.language)
        self._docinfo['copyright'] = builder.config.copyright
        self._docinfo['version'] = builder.config.version
        self._docinfo['manual_group'] = builder.config.project

        # In docutils < 0.11 self.append_header() was never called
        if docutils_version < (0, 11):
            self.body.append(MACRO_DEF)

        # Overwrite admonition label translations with our own
        for label, translation in admonitionlabels.items():
            self.language.labels[label] = self.deunicode(translation)
Exemplo n.º 2
0
    def __init__(self, builder, *args, **kwds):
        BaseTranslator.__init__(self, *args, **kwds)
        self.builder = builder

        self.in_productionlist = 0

        # first title is the manpage title
        self.section_level = -1

        # docinfo set by man_pages config value
        self._docinfo['title'] = self.document.settings.title
        self._docinfo['subtitle'] = self.document.settings.subtitle
        if self.document.settings.authors:
            # don't set it if no author given
            self._docinfo['author'] = self.document.settings.authors
        self._docinfo['manual_section'] = self.document.settings.section

        # docinfo set by other config values
        self._docinfo['title_upper'] = self._docinfo['title'].upper()
        if builder.config.today:
            self._docinfo['date'] = builder.config.today
        else:
            self._docinfo['date'] = ustrftime(builder.config.today_fmt
                                              or _('%B %d, %Y'))
        self._docinfo['copyright'] = builder.config.copyright
        self._docinfo['version'] = builder.config.version
        self._docinfo['manual_group'] = builder.config.project

        # In docutils < 0.11 self.append_header() was never called
        if docutils_version < (0, 11):
            self.body.append(MACRO_DEF)

        # Overwrite admonition label translations with our own
        for label, translation in list(admonitionlabels.items()):
            self.language.labels[label] = self.deunicode(translation)
Exemplo n.º 3
0
    def __init__(self, builder, *args, **kwds):
        BaseTranslator.__init__(self, *args, **kwds)
        self.builder = builder

        self.in_productionlist = 0

        # first title is the manpage title
        self.section_level = -1

        # docinfo set by man_pages config value
        self._docinfo['title'] = self.document.settings.title
        self._docinfo['subtitle'] = self.document.settings.subtitle
        if self.document.settings.authors:
            # don't set it if no author given
            self._docinfo['author'] = self.document.settings.authors
        self._docinfo['manual_section'] = self.document.settings.section

        # docinfo set by other config values
        self._docinfo['title_upper'] = self._docinfo['title'].upper()
        if builder.config.today:
            self._docinfo['date'] = builder.config.today
        else:
            self._docinfo['date'] = ustrftime(builder.config.today_fmt
                                              or _('%B %d, %Y'))
        self._docinfo['copyright'] = builder.config.copyright
        self._docinfo['version'] = builder.config.version
        self._docinfo['manual_group'] = builder.config.project

        # since self.append_header() is never called, need to do this here
        self.body.append(MACRO_DEF)
Exemplo n.º 4
0
    def __init__(self, builder, *args, **kwds):
        BaseTranslator.__init__(self, *args, **kwds)
        self.builder = builder

        self.in_productionlist = 0

        # first title is the manpage title
        self.section_level = -1

        # docinfo set by man_pages config value
        self._docinfo["title"] = self.document.settings.title
        self._docinfo["subtitle"] = self.document.settings.subtitle
        if self.document.settings.authors:
            # don't set it if no author given
            self._docinfo["author"] = self.document.settings.authors
        self._docinfo["manual_section"] = self.document.settings.section

        # docinfo set by other config values
        self._docinfo["title_upper"] = self._docinfo["title"].upper()
        if builder.config.today:
            self._docinfo["date"] = builder.config.today
        else:
            self._docinfo["date"] = ustrftime(builder.config.today_fmt or _("%B %d, %Y"))
        self._docinfo["copyright"] = builder.config.copyright
        self._docinfo["version"] = builder.config.version
        self._docinfo["manual_group"] = builder.config.project

        # since self.append_header() is never called, need to do this here
        self.body.append(MACRO_DEF)

        # Overwrite admonition label translations with our own
        for label, translation in admonitionlabels.items():
            self.language.labels[label] = self.deunicode(translation)
Exemplo n.º 5
0
    def __init__(self, builder, *args, **kwds):
        # type: (Builder, Any, Any) -> None
        BaseTranslator.__init__(self, *args, **kwds)
        self.builder = builder

        self.in_productionlist = 0

        # first title is the manpage title
        self.section_level = -1

        # docinfo set by man_pages config value
        self._docinfo['title'] = self.document.settings.title
        self._docinfo['subtitle'] = self.document.settings.subtitle
        if self.document.settings.authors:
            # don't set it if no author given
            self._docinfo['author'] = self.document.settings.authors
        self._docinfo['manual_section'] = self.document.settings.section

        # docinfo set by other config values
        self._docinfo['title_upper'] = self._docinfo['title'].upper()
        if builder.config.today:
            self._docinfo['date'] = builder.config.today
        else:
            self._docinfo['date'] = format_date(builder.config.today_fmt or _('%b %d, %Y'),
                                                language=builder.config.language)
        self._docinfo['copyright'] = builder.config.copyright
        self._docinfo['version'] = builder.config.version
        self._docinfo['manual_group'] = builder.config.project

        # Overwrite admonition label translations with our own
        for label, translation in admonitionlabels.items():
            self.language.labels[label] = self.deunicode(translation)
Exemplo n.º 6
0
 def depart_caption(self, node):
     # type: (nodes.Element) -> None
     if isinstance(node.parent,
                   nodes.container) and node.parent.get('literal_block'):
         self.body.append('\n')
     else:
         BaseTranslator.depart_caption(self, node)
Exemplo n.º 7
0
   def __init__(self,document):

       Translator.__init__(self,document)

       self.restro = re.compile(r"\*\*(?!\ )(?P<emph>[\\@=\-()\:#+/a-zA-Z0-9_\ ]+)(?<!\ )\*\*")
       self.remph  = re.compile(r"\*(?!\ )(?P<emph>[\\@=\-()\:#+/a-zA-Z0-9_\ ]+)(?<!\ )\*")
       self.keyw   = re.compile(r"(?P<keyw>[a-zA-Z0-9_]+)\s?\:\s?(?P<value>.*?)$")
 
       self.deflist_level = 0

       self.hanging    = 0
       self.inlistitem = 0

       self.intitle    = 0
       self.insection  = 0
       self.insubsect  = 0
       self.section_visited = 0

       self.prevent_nestfont = 0
       self.literalblock = 0

       self.doctitle = ""
       self.docsubtitle = ""
 
       self.defs = {
                'indent' : ('.RS %dm\n', '.RE\n'),

                'definition_list' : ('', ''),
                'definition_list_item' : ('.HP %dm\n', ''),
                'field_name' : ('.HP 5m\n', '\n'),
                'literal' : ('\\fB', '\\fP'),
                'literal_block' : ('.sp\n.nf\n.ft CB\n', '\n.ft P\n.fi\n'),

                'option_list_item' : ('.HP 5m\n', ''),

                'reference' : (r'\fI\%', r'\fP'),
                'emphasis': ('\\fB', '\\fP'),
                'strong' : ('\\fB', '\\fP'),
                'term' : ('\n', '\n'),
                'title_reference' : ('\\fI', '\\fP'),

                'topic-title' : ('.SH ',),
                'sidebar-title' : ('.SH ',),

                'problematic' : ('\n.nf\n', '\n.fi\n'),
                    }

       self._docinfo = {
                "title" : "", "title_upper": "",
                "subtitle" : "",
                "manual_section" : "", "manual_group" : "",
                "author" : [],
                "date" : "",
                "copyright" : "",
                "version" : "",
                "versioninfo" : "",
            }
Exemplo n.º 8
0
 def visit_title(self, node):
     if isinstance(node.parent, addnodes.seealso):
         self.body.append('.IP "')
         return
     elif isinstance(node.parent, nodes.section):
         if self.section_level == 0:
             # skip the document title
             raise nodes.SkipNode
         elif self.section_level == 1:
             self.body.append(".SH %s\n" % self.deunicode(node.astext().upper()))
             raise nodes.SkipNode
     return BaseTranslator.visit_title(self, node)
Exemplo n.º 9
0
 def visit_title(self, node):
     if isinstance(node.parent, addnodes.seealso):
         self.body.append('.IP "')
         return
     elif isinstance(node.parent, nodes.section):
         if self.section_level == 0:
             # skip the document title
             raise nodes.SkipNode
         elif self.section_level == 1:
             self.body.append('.SH %s\n' %
                              self.deunicode(node.astext().upper()))
             raise nodes.SkipNode
     return BaseTranslator.visit_title(self, node)
Exemplo n.º 10
0
 def depart_title(self, node):
     if isinstance(node.parent, addnodes.seealso):
         self.body.append('"\n')
         return
     return BaseTranslator.depart_title(self, node)
Exemplo n.º 11
0
 def visit_footnote(self, node):
     self.ensure_eol()
     BaseTranslator.visit_footnote(self, node)
Exemplo n.º 12
0
 def visit_term(self, node):
     if node.traverse(nodes.strong):
         self.body.append('\n')
     else:
         BaseTranslator.visit_term(self, node)
Exemplo n.º 13
0
 def visit_footnote(self, node):
     # type: (nodes.Node) -> None
     self.ensure_eol()
     BaseTranslator.visit_footnote(self, node)
Exemplo n.º 14
0
 def visit_footnote(self, node):
     # type: (nodes.Node) -> None
     self.ensure_eol()
     BaseTranslator.visit_footnote(self, node)
Exemplo n.º 15
0
 def visit_section(self,node):
     self.section_visited += 1
     Translator.visit_section(self,node)
Exemplo n.º 16
0
 def visit_document(self,node):
     Translator.visit_document(self,node)
     self.doctitle = node.get('title')