コード例 #1
0
ファイル: rst2man.py プロジェクト: nguyenphamvan/VC-20191
#!/home/nguyenpham/PycharmProjects/ThucTapVCCorp_20191/venv/bin/python

# Author:
# Contact: [email protected]
# Copyright: This module has been placed in the public domain.
"""
man.py
======

This module provides a simple command line interface that uses the
man page writer to output from ReStructuredText source.
"""

import locale
try:
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

from docutils.core import publish_cmdline, default_description
from docutils.writers import manpage

description = ("Generates plain unix manual documents.  " +
               default_description)

publish_cmdline(writer=manpage.Writer(), description=description)
コード例 #2
0
ファイル: setup.py プロジェクト: wzyboy/borg
    def gen_man_page(self, name, rst):
        from docutils.writers import manpage
        from docutils.core import publish_string
        from docutils.nodes import inline
        from docutils.parsers.rst import roles

        def issue(name, rawtext, text, lineno, inliner, options={}, content=[]):
            return [inline(rawtext, '#' + text)], []

        roles.register_local_role('issue', issue)
        # We give the source_path so that docutils can find relative includes
        # as-if the document where located in the docs/ directory.
        man_page = publish_string(source=rst, source_path='docs/virtmanpage.rst', writer=manpage.Writer())
        with open('docs/man/%s.1' % name, 'wb') as fd:
            fd.write(man_page)
コード例 #3
0
#!/usr/bin/env python

# Author: Thibault Cohen <*****@*****.**>
# Inspired from http://docutils.sourceforge.net/tools/rst2man.py

import locale
import os
try:
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

from docutils.core import publish_file
from docutils.writers import manpage


output_folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), "manpages")
source_folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), "sources")

for current_folder, subfolders, files in os.walk(source_folder):
    for rst_file in files:
        if rst_file.endswith(".rst"):
            input_file = os.path.join(current_folder, rst_file)
            output_file = os.path.join(output_folder, os.path.splitext(rst_file)[0] + ".8")
            publish_file(source_path=input_file,
                         destination_path=output_file,
                         writer=manpage.Writer()
                         )
コード例 #4
0
 def gen_man_page(self, name, rst):
     from docutils.writers import manpage
     from docutils.core import publish_string
     # We give the source_path so that docutils can find relative includes
     # as-if the document where located in the docs/ directory.
     man_page = publish_string(source=rst, source_path='docs/virtmanpage.rst', writer=manpage.Writer())
     with open('docs/man/%s.1' % name, 'wb') as fd:
         fd.write(man_page)