Пример #1
0
def generate_content(filename, tip_lang):
    click.echo('Preparing content...')
    with open(filename) as f:
        rst = f.read()
    try:
        doctree = publish_doctree(rst)
        content = publish_from_doctree(doctree, writer=confluence.Writer())
    except Exception:
        click.echo('There was error on processing ReST file')
        raise click.Abort()

    metadata = extract_metadata(doctree)
    if metadata:
        tip_lang = tip_lang or metadata.get('warning')
    warning = autogen_warning.get(tip_lang, '')

    return warning + content, metadata
Пример #2
0
def upload(fname, space, parent_id):
    """Upload documentation for CMake module ``fname`` as child of page with
    id ``parent_id``."""
    pagename = path.splitext(path.basename(fname))[0]
    rst = '\n'.join(extract(fname))
    if not rst:
        return
    log.debug('=' * 79)
    log.info('Uploading %s', pagename)
    log.debug('=' * 79)
    log.debug('rST')
    log.debug('-' * 79)
    log.debug(rst)
    log.debug('-' * 79)
    log.debug('Confluence')
    log.debug('-' * 79)
    cwiki = publish_string(rst, writer=confluence.Writer())
    log.debug(cwiki)
    page = {
        'type': 'page',
        'title': pagename,
        'space': {
            'key': space
        },
        'body': {
            'storage': {
                'value': cwiki,
                'representation': 'wiki'
            }
        },
        'ancestors': [{
            'type': 'page',
            'id': parent_id
        }]
    }
    create_or_update(page, space)
Пример #3
0
#!/usr/bin/env python
"""
Confluence Wiki output generator for the Docutils Publisher.
"""

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

from docutils.core import publish_cmdline, default_description

from rst2confluence import confluence
from recommonmark.parser import CommonMarkParser

description = ('Generates documents in Confluence Wiki format from standalone '
               'markdown sources.  ' + default_description)

publish_cmdline(writer=confluence.Writer(),
                description=description,
                parser=CommonMarkParser())
Пример #4
0
#!/usr/bin/env python
"""
A minimal front end to the Docutils Publisher, producing Confluence Wiki output.
"""

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

from docutils.core import publish_cmdline, default_description

from rst2confluence import confluence

description = ('Generates documents in Confluence Wiki format from standalone '
               'reStructuredText sources.  ' + default_description)

publish_cmdline(writer=confluence.Writer(), description=description)