Ejemplo n.º 1
0
def generate_api_block(x, lib):
    block  = ''
    block += '%' * 20 + ' ' + x.name + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsection{\code{%s}}\n' % bindings.LaTeX(x.name)
    block += '\\label{api:c:%s}\n' % x.name
    block += '\\index{%s!C API}\n' % bindings.LaTeX(x.name)
    block += '\\input{\\topdir/%s/fragments/%s}\n\n' % (lib, x.name)
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{ccode}\n'
    block += generate_func(x, lib, sep=' ', padd=8)
    block += '\\end{ccode}\n\n'
    block += '\\paragraph{Parameters:}\n'
    def c_in_label(arg):
        args = [p + ' ' + n for p, n in arg.args]
        return '\\code{' + bindings.LaTeX(', '.join(args)) + '}'
    if lib == 'client':
        args = (bindings.StructClient,) + x.args_in
    elif lib == 'admin':
        args = (bindings.StructAdmin,) + x.args_in
    else:
        assert False
    block += bindings.doc_parameter_list(x.form, args, 'c/' + lib + '/fragments/in',
                                         label_maker=c_in_label)
    block += '\n\\paragraph{Returns:}\n'
    def c_out_label(arg):
        args = [p + '* ' + n for p, n in arg.args]
        return '\\code{' + bindings.LaTeX(', '.join(args)) + '}'
    block += bindings.doc_parameter_list(x.form, x.args_out, 'c/' + lib + '/fragments/out',
                                         label_maker=c_out_label)
    return block
Ejemplo n.º 2
0
Archivo: go.py Proyecto: via/HyperDex
def generate_api_block(x, lib):
    block = ''
    block += '%' * 20 + ' ' + GoIfy(x.name) + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsubsection{\code{%s}}\n' % bindings.LaTeX(GoIfy(x.name))
    block += '\\label{api:Go:%s}\n' % GoIfy(x.name)
    block += '\\index{%s!Go API}\n' % bindings.LaTeX(GoIfy(x.name))
    block += '\\input{\\topdir/%s/fragments/%s}\n\n' % (lib, x.name)
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{gocode}\n'
    typed_args_in = ', '.join([(arg_name(arg) + ' ' + GOTYPEOF(arg)).strip()
                               for arg in x.args_in])
    if x.form == bindings.AsyncCall:
        typed_args_out = return_type_async(x.args_out)
    if x.form == bindings.Iterator:
        typed_args_out = return_type_iter(x.args_out)
    block += 'func (client *Client) {0}({1}) ({2})\n'.format(
        GoIfy(x.name), typed_args_in, typed_args_out)
    block += '\\end{gocode}\n\n'
    block += '\\paragraph{Parameters:}\n'
    block += bindings.doc_parameter_list(
        x.form,
        x.args_in,
        'go/' + lib + '/fragments/in',
        label_maker=bindings.parameters_script_style)
    block += '\n\\paragraph{Returns:}\n'
    frag = 'go/' + lib + '/fragments/return_' + x.form.__name__.lower()
    frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
    block += '\\input{\\topdir/' + frag + '}\n'
    return block
Ejemplo n.º 3
0
def generate_api_block(x, cls='Client'):
    block = ''
    block += '\\subsubsection{{\code{{{0}}}}}\n'.format(bindings.LaTeX(x.name))
    block += '\\label{{api:nodejs:{0}}}\n'.format(x.name)
    block += '\\index{{{0}!Node.js API}}\n'.format(bindings.LaTeX(x.name))
    block += '\\begin{javascriptcode}\n'
    block += generate_api_func(x, cls=cls)
    block += '\\end{javascriptcode}\n'
    block += '\\funcdesc \input{{\\topdir/api/desc/{0}}}\n\n'.format(x.name)
    block += '\\noindent\\textbf{Parameters:}\n'
    block += bindings.doc_parameter_list(
        x.form,
        x.args_in,
        DOCS_IN,
        label_maker=bindings.parameters_script_style)
    block += '\n\\noindent\\textbf{Returns:}\n'
    if x.args_out == (bindings.Status, ):
        if bindings.Predicates in x.args_in:
            block += 'True if predicate, False if not predicate.  Raises exception on error.'
        else:
            block += 'True.  Raises exception on error.'
    elif x.args_out == (bindings.Status, bindings.Attributes):
        block += 'Object if found, nil if not found.  Raises exception on error.'
    elif x.args_out == (bindings.Status, bindings.Count):
        block += 'Number of objects found.  Raises exception on error.'
    elif x.args_out == (bindings.Status, bindings.Description):
        block += 'Description of search.  Raises exception on error.'
    else:
        assert False
    block += '\n'
    return block
Ejemplo n.º 4
0
Archivo: java.py Proyecto: via/HyperDex
def generate_api_block(x, lib):
    block = ''
    block += '%' * 20 + ' ' + x.name + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsubsection{\code{%s}}\n' % bindings.LaTeX(x.name)
    block += '\\label{api:java:%s}\n' % x.name
    block += '\\index{%s!Java API}\n' % bindings.LaTeX(x.name)
    block += '\\input{\\topdir/%s/fragments/%s}\n\n' % (lib, x.name)
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{javacode}\n'
    block += generate_api_norm_func(x)
    block += '\\end{javacode}\n\n'
    block += '\\paragraph{Parameters:}\n'

    def java_label(arg):
        return '\\code{' + bindings.LaTeX(
            JTYPEOF(arg) + ' ' + arg.__name__.lower()) + '}'

    block += bindings.doc_parameter_list(x.form,
                                         x.args_in,
                                         'java/' + lib + '/fragments/in',
                                         label_maker=java_label)
    block += '\n\\paragraph{Returns:}\n'
    frag = 'java/' + lib + '/fragments/return_' + x.form.__name__.lower()
    frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
    block += '\\input{\\topdir/' + frag + '}\n'
    if x.form == bindings.AsyncCall:
        block += '\n\\pagebreak\n'
        block += '\\subsubsection{\code{async\\_%s}}\n' % bindings.LaTeX(
            x.name)
        block += '\\label{api:java:async_%s}\n' % x.name
        block += '\\index{async\_%s!Java API}\n' % bindings.LaTeX(x.name)
        block += '\\input{\\topdir/%s/fragments/%s}\n\n' % (lib, x.name)
        block += '\\paragraph{Definition:}\n'
        block += '\\begin{javacode}\n'
        block += generate_api_async_func(x)
        block += '\\end{javacode}\n\n'
        block += '\\paragraph{Parameters:}\n'
        block += bindings.doc_parameter_list(x.form,
                                             x.args_in,
                                             'java/' + lib + '/fragments/in',
                                             label_maker=java_label)
        block += '\n\\paragraph{Returns:}\n'
        frag = 'java/' + lib + '/fragments/return_async_' + x.form.__name__.lower(
        )
        frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
        block += '\\input{\\topdir/' + frag + '}\n'
        block += '\n\\paragraph{See also:}  This is the asynchronous form of '
        block += '\code{%s}.\n' % bindings.LaTeX(x.name)
    return block
Ejemplo n.º 5
0
def generate_api_block(x, lib):
    block = ''
    block += '%' * 20 + ' ' + x.name + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsubsection{\code{%s}}\n' % bindings.LaTeX(x.name)
    block += '\\label{api:python:%s}\n' % x.name
    block += '\\index{%s!Python API}\n' % bindings.LaTeX(x.name)
    block += '\\input{\\topdir/api/desc/%s}\n\n' % x.name
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{pythoncode}\n'
    block += generate_api_norm_func(x)
    block += '\\end{pythoncode}\n\n'
    block += '\\paragraph{Parameters:}\n'
    block += bindings.doc_parameter_list(
        x.form,
        x.args_in,
        'python/' + lib + '/in',
        label_maker=bindings.parameters_script_style)
    block += '\n\\paragraph{Returns:}\n'
    frag = 'python/' + lib + '/return_' + x.form.__name__.lower()
    frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
    block += '\\input{\\topdir/api/fragments/' + frag + '}\n'
    if x.form == bindings.AsyncCall:
        block += '\n\\pagebreak\n'
        block += '\\subsubsection{\code{async\\_%s}}\n' % bindings.LaTeX(
            x.name)
        block += '\\label{api:python:async_%s}\n' % x.name
        block += '\\index{async\_%s!Python API}\n' % bindings.LaTeX(x.name)
        block += '\\input{\\topdir/api/desc/%s}\n\n' % x.name
        block += '\\paragraph{Definition:}\n'
        block += '\\begin{pythoncode}\n'
        block += generate_api_async_func(x)
        block += '\\end{pythoncode}\n\n'
        block += '\\paragraph{Parameters:}\n'
        block += bindings.doc_parameter_list(
            x.form,
            x.args_in,
            'python/' + lib + '/in',
            label_maker=bindings.parameters_script_style)
        block += '\n\\paragraph{Returns:}\n'
        frag = 'python/' + lib + '/return_async_' + x.form.__name__.lower()
        frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
        block += '\\input{\\topdir/api/fragments/' + frag + '}\n'
        block += '\n\\paragraph{See also:}  This is the asynchronous form of '
        block += '\code{%s}.\n' % bindings.LaTeX(x.name)
    return block
Ejemplo n.º 6
0
def generate_api_block(x, struct='hyperdex_client'):
    block = ''
    block += '%' * 20 + ' ' + x.name + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsubsection{\code{%s}}\n' % bindings.LaTeX(x.name)
    block += '\\label{api:c:%s}\n' % x.name
    block += '\\index{%s!C API}\n' % bindings.LaTeX(x.name)
    block += '\\input{\\topdir/api/desc/%s}\n\n' % x.name
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{ccode}\n'
    block += generate_func(x, struct=struct, sep=' ', padd=8)
    block += '\\end{ccode}\n\n'
    block += '\\paragraph{Parameters:}\n'
    block += bindings.doc_parameter_list(
        x.form, x.args_in, DOCS_IN, label_maker=bindings.parameters_c_style)
    block += '\n\\paragraph{Returns:}\n'
    block += bindings.doc_parameter_list(
        x.form, x.args_out, DOCS_OUT, label_maker=bindings.parameters_c_style)
    return block
Ejemplo n.º 7
0
def generate_api_block(x, lib):
    block  = ''
    block += '%' * 20 + ' ' + x.name + ' ' + '%' * 20 + '\n'
    block += '\\pagebreak\n'
    block += '\\subsubsection{\code{%s}}\n' % bindings.LaTeX(x.name)
    block += '\\label{api:nodejs:%s}\n' % x.name
    block += '\\index{%s!Node.js API}\n' % bindings.LaTeX(x.name)
    block += '\\input{\\topdir/%s/fragments/%s}\n\n' % (lib, x.name)
    block += '\\paragraph{Definition:}\n'
    block += '\\begin{javascriptcode}\n'
    block += generate_api_func(x)
    block += '\\end{javascriptcode}\n'
    block += '\\paragraph{Parameters:}\n'
    block += bindings.doc_parameter_list(x.form, x.args_in, 'node.js/' + lib + '/fragments/in',
                                         label_maker=bindings.parameters_script_style)
    block += '\n\\paragraph{Returns:}\n'
    frag  = 'node.js/' + lib + '/fragments/return_' + x.form.__name__.lower()
    frag += '__' + '_'.join([a.__name__.lower() for a in x.args_out])
    block += '\\input{\\topdir/' + frag + '}\n'
    return block
Ejemplo n.º 8
0
 def c_out_label(arg):
     args = [p + '* ' + n for p, n in arg.args]
     return '\\code{' + bindings.LaTeX(', '.join(args)) + '}'
Ejemplo n.º 9
0
Archivo: java.py Proyecto: via/HyperDex
 def java_label(arg):
     return '\\code{' + bindings.LaTeX(
         JTYPEOF(arg) + ' ' + arg.__name__.lower()) + '}'