def write_docs(dataset_name, path): """Generate dataset documentation: release notes, coverage notes, and codebook. Args: dataset_name (str): The dataverse of the dataset. path (Path): Destination directory for the documentation. Returns: None >>> write_docs('2016-precinct-president.yaml', 'output') """ if isinstance(path, str): path = Path(path).resolve() meta = Meta(dataset_name) Template('codebook.jinja').write( meta.to_dict(), path / 'codebook-{}.md'.format(meta.dataset_name)) Template('release_notes.jinja').write( meta.to_dict(), path / 'release-notes-{}.md'.format(meta.dataset_name)) Template('coverage_notes.jinja').write( meta.to_dict(), path / 'coverage-notes-{}.md'.format(meta.dataset_name)) RdTemplate('r_doc.jinja').write( meta.to_dict(), path / '{}.Rd'.format(meta.dataset_meta['r_alias'])) logging.info('Wrote docs to {}'.format(path))
def test_read_template(): """Template finds .jinja files in templates directory""" template = Template('codebook.jinja') assert template.text template = Template('coverage_notes.jinja') assert template.text template = Template('r_doc.jinja') assert template.text template = Template('precinct_repo_readme.jinja') assert template.text
def write_precinct_readme(): meta = Meta('2016-precinct-president.yaml') return Template('precinct_repo_readme.jinja').write( meta.to_dict(), Path('output') / 'README.md'.format(meta.dataset_name))
def test_render_readme(): """README template renders without error""" template = Template('precinct_repo_readme.jinja') assert template.write(meta.to_dict())
def test_render_r_doc(): """Rd template renders without error""" template = Template('r_doc.jinja') assert template.write(meta.to_dict())
def test_render_coverage(): """Coverage template renders without error""" template = Template('coverage_notes.jinja') assert template.write(meta.to_dict())
def test_render_codebook(): """Codebook template renders without error""" template = Template('codebook.jinja') assert template.write(meta.to_dict())