Esempio n. 1
0
def write_all_examples(execute=True):
    notebook_directory = os.path.join(os.path.dirname(__file__),
                                      '..', 'altair', 'notebooks', 'auto_examples')
    if not os.path.exists(notebook_directory):
        os.makedirs(notebook_directory)

    index_dict = {}
    for filename, spec in iter_examples():
        create_example_notebook(filename, spec, notebook_directory,
                                execute=execute, index_dict=index_dict)

    print("writing Index.ipynb")
    write_index(notebook_directory, index_dict)
Esempio n. 2
0
def write_all_examples(execute=True):
    notebook_directory = os.path.join(os.path.dirname(__file__), '..',
                                      'altair', 'notebooks', 'auto_examples')
    if not os.path.exists(notebook_directory):
        os.makedirs(notebook_directory)

    index_dict = {}
    for filename, spec in iter_examples():
        create_example_notebook(filename,
                                spec,
                                notebook_directory,
                                execute=execute,
                                index_dict=index_dict)

    print("writing Index.ipynb")
    write_index(notebook_directory, index_dict)
Esempio n. 3
0
def populate_examples(**kwds):
    """Iterate through Altair examples and extract code"""

    examples = sorted(iter_examples(), key=itemgetter('name'))

    for example in examples:
        docstring, category, code, lineno =\
            get_docstring_and_rest(example['filename'])
        example.update(kwds)
        if category is None:
            category = 'general'
        example.update({'docstring': docstring,
                        'title': docstring.strip().split('\n')[0],
                        'code': code,
                        'category': category.title(),
                        'lineno': lineno})

    return examples
Esempio n. 4
0
def populate_examples(**kwds):
    """Iterate through Altair examples and extract code"""

    examples = sorted(iter_examples(), key=itemgetter('name'))

    for example in examples:
        docstring, category, code, lineno =\
            get_docstring_and_rest(example['filename'])
        example.update(kwds)
        if category is None:
            category = 'other charts'
        example.update({'docstring': docstring,
                        'title': docstring.strip().split('\n')[0],
                        'code': code,
                        'category': category.title(),
                        'lineno': lineno})

    return examples
Esempio n. 5
0
def write_all_examples(execute=True):
    notebook_directory = os.path.join(os.path.dirname(__file__),
                                      '..', 'notebooks',
                                      'examples')
    
    # Remove old examples before starting again
    if not os.path.exists(notebook_directory):
        os.makedirs(notebook_directory)

    for example in os.listdir(notebook_directory):
        if os.path.splitext(example)[1] == '.ipynb':
            os.remove(os.path.join(notebook_directory, example))

    index_dict = {}
    for filename, spec in iter_examples():
        create_example_notebook(filename, spec, notebook_directory,
                                execute=execute, index_dict=index_dict)

    print("writing Index.ipynb")
    write_index(notebook_directory, index_dict)
Esempio n. 6
0
def populate_examples(**kwds):
    """Iterate through Altair examples and extract code"""

    examples = sorted(iter_examples(), key=itemgetter("name"))

    for example in examples:
        docstring, category, code, lineno = get_docstring_and_rest(
            example["filename"])
        example.update(kwds)
        if category is None:
            category = "other charts"
        example.update({
            "docstring": docstring,
            "title": docstring.strip().split("\n")[0],
            "code": code,
            "category": category.title(),
            "lineno": lineno,
        })

    return examples