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 isREADME-TEMPLATE.md).To change the output file, pass in
output_path(default isREADME.md).To supply data to your template, pass in
context(default isNone).To add your own filters, simply set
filters(default isNone).
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.Templatefrom 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.