예제 #1
0
 def __init__(self, document, cite=True):
     self.handlers = {}
     self.doc = deepcopy(document)
     if cite:
         self.doc.add(c.Hr())
         self.doc.add(
             c.Footer(
                 c.P(
                     c.Small(
                         c.Cite(
                             'This document was generated with ',
                             c.A('Docify',
                                 'https://github.com/rapidstack/Docify'),
                             '.')))))
예제 #2
0
    def create(workspace, hide_cred=False):
        '''Create and return document object from workspace object'''

        doc = Document(c.H1(workspace.config.WORKSPACE_TITLE))
        if workspace.config.WORKSPACE_DESCRIPTION:
            doc.add(c.P(workspace.config.WORKSPACE_DESCRIPTION))
        doc.add(c.Hr())

        for req_id in workspace.saved_requests:
            req = workspace.get_saved_request(req_id)
            api = req.endpoint.api
            headers = api.session.headers.copy()

            if hide_cred:
                if 'Authorization' in headers:
                    headers['Authorization'] = '*****'
                if 'Proxy-Authorization' in headers:
                    headers['Proxy-Authorization'] = '*****'

            lnk = re.sub('[^a-zA-Z0-9-]', '-', str(req_id))
            doc.add(
                c.Section(
                    c.H2(
                        c.B(req.method),
                        c.Nbsp(),
                        c.A(req_id, href='/#' + lnk),
                        id=lnk,
                    ),
                    c.H3('Endpoint'),
                    c.Pre(c.Code(api.endpoint)),
                    c.H3('Headers'),
                    c.Pre(
                        c.Code('\n'.join([
                            '{}: {}'.format(k, v) for k, v in headers.items()
                        ], ))),
                ))

            if api.session.auth:
                if hide_cred:
                    username, password = ('*****', '*****')
                else:
                    username, password = api.session.auth

                doc.add(
                    c.Section(
                        c.H3('Authentication'),
                        c.Section(
                            c.B('Username: '******'Password:'******'GET':
                doc.add(
                    c.Section(
                        c.H3('Body'),
                        c.Pre(c.Code(json.dumps(req.kwargs, indent=4))),
                    ))
            doc.add(c.P(c.Nbsp()))
        return doc
예제 #3
0
파일: doc.py 프로젝트: sayanarijit/Docify
import sys

from docify import Document, components as c
from docify.formatters.html import HTML
from docify.formatters.markdown import Markdown
from docify.formatters.html_bootstrap import HTMLBootstrap

doc = Document(
    c.Section(
        c.H1('Docify'), c.P('Simple, flexible python document generator'),
        c.P(
            c.A(c.Img(alt='PyPI version',
                      src='https://img.shields.io/pypi/v/Docify.svg'),
                href='https://pypi.org/project/Docify'), c.Nbsp(),
            c.A(c.Img(
                alt='Build Status',
                src='https://travis-ci.org/rapidstack/Docify.svg?branch=master'
            ),
                href='https://travis-ci.org/rapidstack/Docify'), c.Nbsp(),
            c.A(c.Img(
                alt='Documentation Status',
                src=
                'https://readthedocs.org/projects/docify/badge/?version=latest'
            ),
                href='https://docify.readthedocs.io/en/latest/?badge=latest'))
    ), c.P(c.Nbsp()),
    c.Section(
        c.H2('Introduction'),
        c.P('Docify helps you write documents in different formats from a ',
            c.B('Python object.')),
        c.Blockquote(c.B('Note:'), ' It\'s not a document ', c.I('converter'),
예제 #4
0
파일: doc.py 프로젝트: sayanarijit/Docify
from docify import Document, components as c

doc = Document(
    c.H1('Header 1'), c.H2('Header 2'), c.H3('Header 3'), c.H4('Header 4'),
    c.H5('Header 5'), c.H6('Header 6'), c.P(c.I('Italic')), c.P(c.B('Bold')),
    c.P(c.B(c.I('Italic') + c.Nbsp() + 'inside bold')),
    c.P(c.I(c.B('Bold'), ' inside italic')), c.Blockquote('Blockquote'),
    c.P(c.Del('Strikethrough')), c.Pre(c.Code('# Code block\n:(){ :|:& };:')),
    c.P(c.Span('Inline code: ', c.Code(':(){ :|:& };:'))),
    c.P(c.Span('Span', ' -> ', c.Span('Nested span'))),
    c.Ol(
        c.Li('Item 1'), c.Li(c.A('Item 2', href='#')),
        c.Ul(c.Li('Item 2.1'), c.Li(c.A('Item 2.2', href='#')),
             c.Ol(c.Li('Item 2.2.1'), c.Li(c.A('Item 2.2.2', href='#'))))),
    c.Table(c.Tr(c.Th('Field'), c.Th('Value')), c.Tr(c.Td('x'), c.Td(100)),
            c.Tr(c.Td('y'), c.Td(200))),
    c.P(
        c.Img(src='https://img.shields.io/badge/docify-image_test-green.svg',
              alt='Image Test')), c.Hr(),
    c.A('google', href='https://google.com'), c.Br(),
    c.A(c.Img(src='https://img.shields.io/badge/docify-image_test-green.svg',
              alt='Image Test'),
        href='https://img.shields.io/badge/docify-image_test-green.svg'))