예제 #1
0
def generate_list_file(outputs, path, conf=None):
    dirname = os.path.dirname(path)

    if conf is None:
        conf = get_conf()

    if conf.project.name == 'ecosystem':
        url = 'http://docs.mongodb.org/ecosystem'
    elif conf.project.name == 'mms':
        if conf.project.edition == 'hosted':
            url = '/'.join(['http://mms.mongodb.com/help-hosted', get_manual_path()])
        else:
            url = 'http://mms.mongodb.com/help'
    else:
        url = '/'.join(['http://docs.mongodb.org', get_manual_path()])

    if not os.path.exists(dirname):
        os.mkdir(dirname)

    with open(path, 'w') as f:
        for fn in outputs:
            f.write( '/'.join([ url, 'json', fn.split('/', 3)[3:][0]]) )
            f.write('\n')

    puts('[json]: rebuilt inventory of json output.')
예제 #2
0
def pdf_makefile(name, tag=None, edition=None):
    if tag is None:
        name_tagged = name
        name_tagged_branch_pdf = "-".join([name, utils.get_branch()]) + ".pdf"
    else:
        name_tagged = "-".join([name, tag])
        name_tagged_branch_pdf = "-".join([name, tag, utils.get_branch()]) + ".pdf"

    if conf.git.remote.upstream.endswith("mms-docs"):
        site_url = "http://mms.10gen.com"
    else:
        site_url = "http://docs.mongodb.org/" + get_manual_path()

    if edition is None:
        branch_staging = paths["branch-staging"]
        branch_output = paths["branch-output"]
    else:
        if edition == "saas":
            branch_staging = os.path.join(paths["public"], edition)
            branch_output = os.path.join(paths["output"], edition)
            site_url += "/help"
        elif edition == "hosted":
            branch_staging = os.path.join(paths["public"], edition, utils.get_branch())
            branch_output = os.path.join(paths["output"], edition, utils.get_branch())
            site_url += "/help-hosted/" + get_manual_path()

    pdf_latex_command = 'TEXINPUTS=".:{0}/latex/:" pdflatex --interaction batchmode --output-directory {0}/latex/ $(LATEXOPTS)'.format(
        branch_output
    )
    link_correction = "'s%\\\\\code\{/%\\\\\code\{" + site_url + "/%g'"

    name_tagged_pdf = name_tagged + ".pdf"

    generated_latex = "{0}/latex/{1}.tex".format(branch_output, name)
    built_tex = "{0}/latex/{1}.tex".format(branch_output, name_tagged)

    built_pdf = "{0}/latex/{1}".format(branch_output, name_tagged_pdf)
    staged_pdf_branch = "{0}/{1}".format(branch_staging, name_tagged_branch_pdf)
    staged_pdf = "{0}/{1}".format(branch_staging, name_tagged_pdf)

    m.section_break(name)
    m.target(target=generated_latex, dependency="latex")
    m.job("sed $(SED_ARGS_FILE) -e {0} -e {0} -e {1} {2}".format(correction, link_correction, generated_latex))
    m.msg("[latex]: fixing $@ TeX from the Sphinx output.")

    m.target(target=built_tex, dependency=generated_latex)
    m.job("fab process.input:{0} process.output:{1} process.copy_if_needed:pdf".format(generated_latex, built_tex))
    m.msg('[pdf]: updated "' + built_tex + '" for pdf generation.')

    pdf_builder(built_pdf, built_tex, pdf_latex_command)

    m.target(target=staged_pdf_branch, dependency=built_pdf)
    m.job("cp {0} {1}".format(built_pdf, staged_pdf_branch))
    m.msg("[pdf]: migrated " + staged_pdf)

    m.target(target=staged_pdf, dependency=staged_pdf_branch)
    m.job("fab process.input:{0} process.output:{1} process.create_link".format(name_tagged_branch_pdf, staged_pdf))
    m.msg("[pdf]: created link for " + staged_pdf)

    return staged_pdf
예제 #3
0
파일: meta.py 프로젝트: Bernadskaya/docs
def generate_meta():
    m.section_break('branch/release meta', block='rel')
    m.var('manual-branch', MANUAL_BRANCH, block='rel')
    m.var('current-branch', str(utils.get_branch()), block='rel')
    m.var('last-commit', str(utils.get_commit()), block='rel')
    m.var('current-if-not-manual', str(get_manual_path()), block='rel')

    paths = render_paths(True)

    m.section_break('file system paths', block='paths')
    m.var('output', paths['output'], block='paths')
    m.var('public-output', paths['public'], block='paths')
    m.var('branch-output', paths['branch-output'], block='paths')
    m.var('rst-include', paths['includes'], block='paths')
    m.var('branch-source', paths['branch-source'], block='paths')
    m.var('public-branch-output', paths['branch-staging'], block='paths')

    generated_makefiles = []

    m.newline()
    for target in dynamic_makefiles():
        file ='/'.join([paths['output'], "makefile." + target])
        cloth = '/'.join([paths['tools'], "makecloth", target + '.py'])
        
        generated_makefiles.append(file)
        m.raw(['-include ' + paths['output'] + '/makefile.' + target])

        m.target(target=file, dependency=cloth, block='makefiles')
        m.job(' '.join(["$(PYTHONBIN)", cloth, file]))
        m.newline()

    m.newline()

    m.target('.PHONY',  generated_makefiles)
예제 #4
0
파일: process.py 프로젝트: joeytwiddle/docs
def json_output():
    if env.input_file is None or env.output_file is None:
        abort('[json]: you must specify input and output files.')

    with open(env.input_file, 'r') as f:
        document = f.read()

    doc = json.loads(document)
    
    if 'body' not in doc:
        pass
    else:
        text = doc['body'].encode('ascii', 'ignore')

        text = re.sub('<[^>]*>', '', text)
        text = re.sub('&#8220;', '"', text)
        text = re.sub('&#8221;', '"', text)
        text = re.sub('&#8216;', "'", text)
        text = re.sub('&#8217;', "'", text)
        text = re.sub('&#\d{4};', '', text)

        doc['text'] = ' '.join(text.split('\n')).strip()

        url = [ 'http://docs.mongodb.org', get_manual_path() ]
        url.extend(env.input_file.rsplit('.', 1)[0].split('/')[3:])

        doc['url'] = '/'.join(url)

    with open(env.output_file, 'w') as f:
        f.write(json.dumps(doc))
예제 #5
0
def json_output():
    if env.input_file is None or env.output_file is None:
        abort('[json]: you must specify input and output files.')

    with open(env.input_file, 'r') as f:
        document = f.read()

    doc = json.loads(document)

    if 'body' not in doc:
        pass
    else:
        text = doc['body'].encode('ascii', 'ignore')

        text = re.sub('<[^>]*>', '', text)
        text = re.sub('&#8220;', '"', text)
        text = re.sub('&#8221;', '"', text)
        text = re.sub('&#8216;', "'", text)
        text = re.sub('&#8217;', "'", text)
        text = re.sub('&#\d{4};', '', text)

        doc['text'] = ' '.join(text.split('\n')).strip()

        url = ['http://docs.mongodb.org', get_manual_path()]
        url.extend(env.input_file.rsplit('.', 1)[0].split('/')[3:])

        doc['url'] = '/'.join(url)

    with open(env.output_file, 'w') as f:
        f.write(json.dumps(doc))
예제 #6
0
def process_json_file(input_fn, output_fn, regexes, conf=None):
    with open(input_fn, 'r') as f:
        document = f.read()

    doc = json.loads(document)

    if 'body' in doc:
        text = doc['body'].encode('ascii', 'ignore')
        text = munge_content(text, regexes)

        doc['text'] = ' '.join(text.split('\n')).strip()

    if 'title' in doc:
        title = doc['title'].encode('ascii', 'ignore')
        title = munge_content(title, regexes)

        doc['title'] = title

    if conf.project.name == 'mms':
        if conf.project.edition == 'hosted':
            url = ['http://mms.mongodb.com/help-hosted', get_manaul_path() ]
        else:
            url = ['http://mms.mongodb.com/help' ]
    else:
        url = [ 'http://docs.mongodb.org', get_manual_path() ]

    url.extend(input_fn.rsplit('.', 1)[0].split(os.path.sep)[3:])
    doc['url'] = '/'.join(url) + '/'

    with open(output_fn, 'w') as f:
        f.write(json.dumps(doc))

    puts('[json]: generated a processed json file: ' + output_fn)
예제 #7
0
def generate_meta():
    m.section_break('branch/release meta', block='rel')
    m.var('manual-branch', MANUAL_BRANCH, block='rel')
    m.var('current-branch', str(utils.get_branch()), block='rel')
    m.var('last-commit', str(utils.get_commit()), block='rel')
    m.var('current-if-not-manual', str(get_manual_path()), block='rel')

    paths = render_paths(True)

    m.section_break('file system paths', block='paths')
    m.var('output', paths['output'], block='paths')
    m.var('public-output', paths['public'], block='paths')
    m.var('branch-output', paths['branch-output'], block='paths')
    m.var('rst-include', paths['includes'], block='paths')
    m.var('branch-source', paths['branch-source'], block='paths')
    m.var('public-branch-output', paths['branch-staging'], block='paths')

    generated_makefiles = []

    m.newline()
    for target in dynamic_makefiles():
        file = '/'.join([paths['output'], "makefile." + target])
        cloth = '/'.join([paths['tools'], "makecloth", target + '.py'])

        generated_makefiles.append(file)
        m.raw(['-include ' + paths['output'] + '/makefile.' + target])

        m.target(target=file, dependency=cloth, block='makefiles')
        m.job(' '.join(["$(PYTHONBIN)", cloth, file]))
        m.newline()

    m.newline()

    m.target('.PHONY', generated_makefiles)
예제 #8
0
def generate_list_file(outputs, path):
    with open(path, 'w') as f:
        branch =get_manual_path()

        for fn in outputs:
            url = [ 'http://docs.mongodb.org', branch ]
            url.extend(fn.split('/', 3)[3:])
            url = '/'.join(url)

            f.write(url + '\n')
예제 #9
0
파일: meta.py 프로젝트: riboflavin/docs
def generate_meta():
    m.section_break("branch/release meta", block="rel")
    m.var("manual-branch", MANUAL_BRANCH, block="rel")
    m.var("current-branch", str(utils.get_branch()), block="rel")
    m.var("last-commit", str(utils.get_commit()), block="rel")
    m.var("current-if-not-manual", str(get_manual_path()), block="rel")

    paths = render_paths(True)

    m.section_break("file system paths", block="paths")
    m.var("output", paths["output"], block="paths")
    m.var("public-output", paths["public"], block="paths")
    m.var("branch-output", paths["branch-output"], block="paths")
    m.var("rst-include", paths["includes"], block="paths")
    m.var("branch-source", paths["branch-source"], block="paths")
    m.var("public-branch-output", paths["branch-staging"], block="paths")
예제 #10
0
def generate_meta():
    m.section_break('branch/release meta', block='rel')
    m.var('manual-branch', docs_meta.MANUAL_BRANCH, block='rel')
    m.var('current-branch', str(docs_meta.get_branch()), block='rel')
    m.var('last-commit', str(docs_meta.get_commit()), block='rel')
    m.var('current-if-not-manual', str(docs_meta.get_manual_path()), block='rel')

    paths = docs_meta.render_paths(True)

    m.section_break('file system paths', block='paths')
    m.var('output', paths['output'], block='paths')
    m.var('public-output', paths['public'], block='paths')
    m.var('branch-output', paths['branch-output'], block='paths')
    m.var('rst-include', paths['includes'], block='paths')
    m.var('branch-source', paths['branch-source'], block='paths')
    m.var('public-branch-output', paths['branch-staging'], block='paths')
예제 #11
0
def pdf_makefile(name, tag=None, edition=None):
    if tag is None:
        name_tagged = name
        name_tagged_branch_pdf = '-'.join([name, utils.get_branch()]) + '.pdf'
    else:
        name_tagged = '-'.join([name, tag])
        name_tagged_branch_pdf = '-'.join([name, tag,
                                           utils.get_branch()]) + '.pdf'

    if conf.git.remote.upstream.endswith('mms-docs'):
        site_url = 'http://mms.10gen.com'
    else:
        site_url = 'http://docs.mongodb.org/' + get_manual_path()

    if edition is None:
        branch_staging = paths['branch-staging']
        branch_output = paths['branch-output']
    else:
        if edition == 'saas':
            branch_staging = os.path.join(paths['public'], edition)
            branch_output = os.path.join(paths['output'], edition)
            site_url += "/help"
        elif edition == 'hosted':
            branch_staging = os.path.join(paths['public'], edition,
                                          utils.get_branch())
            branch_output = os.path.join(paths['output'], edition,
                                         utils.get_branch())
            site_url += '/help-hosted/' + get_manual_path()

    pdf_latex_command = 'TEXINPUTS=".:{0}/latex/:" pdflatex --interaction batchmode --output-directory {0}/latex/ $(LATEXOPTS)'.format(
        branch_output)
    link_correction = "'s%\\\\\code\{/%\\\\\code\{" + site_url + "/%g'"

    name_tagged_pdf = name_tagged + '.pdf'

    generated_latex = '{0}/latex/{1}.tex'.format(branch_output, name)
    built_tex = '{0}/latex/{1}.tex'.format(branch_output, name_tagged)

    built_pdf = '{0}/latex/{1}'.format(branch_output, name_tagged_pdf)
    staged_pdf_branch = '{0}/{1}'.format(branch_staging,
                                         name_tagged_branch_pdf)
    staged_pdf = '{0}/{1}'.format(branch_staging, name_tagged_pdf)

    m.section_break(name)
    m.target(target=generated_latex, dependency='latex')
    m.job('sed $(SED_ARGS_FILE) -e {0} -e {0} -e {1} {2}'.format(
        correction, link_correction, generated_latex))
    m.msg('[latex]: fixing $@ TeX from the Sphinx output.')

    m.target(target=built_tex, dependency=generated_latex)
    m.job(
        'fab process.input:{0} process.output:{1} process.copy_if_needed:pdf'.
        format(generated_latex, built_tex))
    m.msg('[pdf]: updated "' + built_tex + '" for pdf generation.')

    pdf_builder(built_pdf, built_tex, pdf_latex_command)

    m.target(target=staged_pdf_branch, dependency=built_pdf)
    m.job('cp {0} {1}'.format(built_pdf, staged_pdf_branch))
    m.msg('[pdf]: migrated ' + staged_pdf)

    m.target(target=staged_pdf, dependency=staged_pdf_branch)
    m.job(
        'fab process.input:{0} process.output:{1} process.create_link'.format(
            name_tagged_branch_pdf, staged_pdf))
    m.msg('[pdf]: created link for ' + staged_pdf)

    return staged_pdf
예제 #12
0
파일: conf.py 프로젝트: Necromos/docs
html_copy_source = False
html_use_smartypants = True
html_domain_indices = True
html_use_index = True
html_split_index = False
html_show_sourcelink = False
html_show_sphinx = True
html_show_copyright = True

manual_edition_path = '{0}/{1}/MongoDB-manual'.format(conf.project.url, conf.git.branches.current)

html_theme_options = {
    'branch': conf.git.branches.current,
    'pdfpath': manual_edition_path + '.pdf',
    'epubpath': manual_edition_path + '.epub',
    'manual_path': get_manual_path(conf),
    'translations': languages,
    'language': language,
    'repo_name': 'docs',
    'jira_project': 'DOCS',
    'google_analytics': 'UA-7301842-8',
    'project': 'manual',
    'version': version,
    'version_selector': get_versions(conf),
    'stable': conf.version.stable,
}

html_sidebars = {
    '**': ['sidebar-nav-manual.html'],
}
html_sidebars['**'].append('formats.html')
예제 #13
0
html_use_smartypants = True
html_domain_indices = True
html_use_index = True
html_split_index = False
html_show_sourcelink = False
html_show_sphinx = True
html_show_copyright = True

manual_edition_path = '{0}/{1}/MongoDB-manual'.format(
    conf.project.url, conf.git.branches.current)

html_theme_options = {
    'branch': conf.git.branches.current,
    'pdfpath': manual_edition_path + '.pdf',
    'epubpath': manual_edition_path + '.epub',
    'manual_path': get_manual_path(conf),
    'translations': languages,
    'language': language,
    'repo_name': 'docs',
    'jira_project': 'DOCS',
    'google_analytics': 'UA-7301842-8',
    'project': 'manual',
    'version': version,
    'version_selector': get_versions(conf),
    'stable': conf.version.stable,
}

html_sidebars = {
    '**': ['sidebar-nav-manual.html'],
}
html_sidebars['**'].append('formats.html')
예제 #14
0
파일: pdfs.py 프로젝트: pythonegrove/docs
import sys
import os.path

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
                                             '../')))
import utils
from makecloth import MakefileCloth
from docs_meta import render_paths, get_manual_path

m = MakefileCloth()

paths = render_paths('dict')

correction = "'s/(index|bfcode)\{(.*!*)*--(.*)\}/\\1\{\\2-\{-\}\\3\}/g'"
link_correction = "'s%\\\\\code\{/%\\\\\code\{http://docs.mongodb.org/" + get_manual_path(
) + "/%g'"
pdf_latex_command = 'TEXINPUTS=".:{0}/latex/:" pdflatex --interaction batchmode --output-directory {0}/latex/ $(LATEXOPTS)'.format(
    paths['branch-output'])


def pdf_makefile(name, tag):
    name_tagged = '-'.join([name, tag])
    name_tagged_pdf = name_tagged + '.pdf'
    name_tagged_branch_pdf = '-'.join([name, tag, utils.get_branch()]) + '.pdf'

    generated_latex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name)
    built_tex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name_tagged)

    built_pdf = '{0}/latex/{1}'.format(paths['branch-output'], name_tagged_pdf)
    staged_pdf_branch = '{0}/{1}'.format(paths['branch-staging'],
                                         name_tagged_branch_pdf)
예제 #15
0
파일: pdfs.py 프로젝트: LeEnno/docs
#!/usr/bin/python

import sys
import os.path

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
import utils
from makecloth import MakefileCloth
from docs_meta import render_paths, get_manual_path

m = MakefileCloth()

paths = render_paths('dict')

correction = "'s/(index|bfcode)\{(.*!*)*--(.*)\}/\\1\{\\2-\{-\}\\3\}/g'"
link_correction = "'s%\\\\\code\{/%\\\\\code\{http://docs.mongodb.org/" + get_manual_path() + "/%g'"
pdf_latex_command = 'TEXINPUTS=".:{0}/latex/:" pdflatex --interaction batchmode --output-directory {0}/latex/ $(LATEXOPTS)'.format(paths['branch-output'])

def pdf_makefile(name, tag):
    name_tagged = '-'.join([name, tag])
    name_tagged_pdf = name_tagged + '.pdf'
    name_tagged_branch_pdf = '-'.join([name, tag,  utils.get_branch()]) + '.pdf'

    generated_latex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name)
    built_tex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name_tagged)

    built_pdf = '{0}/latex/{1}'.format(paths['branch-output'], name_tagged_pdf)
    staged_pdf_branch = '{0}/{1}'.format(paths['branch-staging'], name_tagged_branch_pdf)
    staged_pdf = '{0}/{1}'.format(paths['branch-staging'], name_tagged_pdf)

    m.section_break(name)