API Documentation

Table of Contents

Basic API Usage

This section gives you a brief introduction to the Python API for profile-readme:

from profile_readme import get_github_context, ProfileGenerator


context = {}
filters = {}

# If you don't need the GitHub data you can remove the next line
context.update(**get_github_context('octocat'))


ProfileGenerator.render(
    template_path="README-TEMPLATE.md",
    output_path="README.md",
    context=context,
    filters=filters
)

To change behavior, pass the appropriate keyword arguments to ProfileGenerator.render.

  • To change which template to use, set template_path (default is README-TEMPLATE.md).

  • To change the output file, pass in output_path (default is README.md).

  • To supply data to your template, pass in context (default is None).

  • To add your own filters, simply set filters (default is None).

Note

By default the render command pasess the output of the get_github_context to the template context.

API

This part of the documentation lists the full API reference of all public classes and functions.

class profile_readme.ProfileGenerator(template_path='README-TEMPLATE.md', output_path='README.md', context=None, filters=None)

Simple Jinja2 profile README generator.

Parameters
  • template_path (str) – A string representing the path of the template. Defaults to ‘README-TEMPLATE.md’.

  • output_path (str) – A string representing the output path of the README.md file. Defaults to ‘README.md’.

  • context (dict) – A dictonary of data to supply to the template. Defaults to None.

  • filters (dict) – A dictionary of filters to add to the Environment. Defaults to None.

get_context()

Get the context for the template.

get_template()

Get a jinja2.Template from the environment.

classmethod render(template_path='README-TEMPLATE.md', output_path='README.md', context=None, filters=None)

Reander the profile README file.

Parameters
  • template_path (str) – A string representing the path of the template. Defaults to ‘README-TEMPLATE.md’.

  • output_path (str) – A string representing the output path of the README.md file. Defaults to ‘README.md’.

  • context (dict) – A dictonary of data to supply to the template. Defaults to None.

  • filters (dict) – A dictionary of filters to add to the Environment. Defaults to None.

render_template()

Reander the profile README file.

profile_readme.get_github_context(user)

Get the data from the GitHub API for the template.

Parameters

user (str) – The GitHub user name.