Commit 18d6ca56 authored by Willi Rath's avatar Willi Rath

Add acknowledgements/citations to rendered Readme

This addresses #57
parent 7e87636c
......@@ -354,6 +354,8 @@ class ReadmeRenderer(Renderer):
People: {{people}}
{{repo_description}}
{{acknowledgement_parsed}}
{{citations_parsed}}
## Known problems
......@@ -395,6 +397,15 @@ class ReadmeRenderer(Renderer):
def __init__(self, yaml_dict=None, *args, **kwargs):
"""Add credentials file info but use super's init otherwise."""
yaml_dict = self._maybe_include_credentials(yaml_dict)
yaml_dict = self._maybe_include_acknowledgements(yaml_dict)
yaml_dict = self._maybe_include_citations(yaml_dict)
super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args,
**kwargs)
@static
def _maybe_include_credentials(yaml_dict):
if "credential_files" not in yaml_dict:
yaml_dict["maybe_credentials"] = ""
else:
......@@ -404,9 +415,46 @@ class ReadmeRenderer(Renderer):
"- \"{}\"".format(el)
for el in yaml_dict["credential_files"]))
yaml_dict["maybe_credentials"] = textwrap.dedent(cred_string)
super(ReadmeRenderer, self).__init__(yaml_dict=yaml_dict, *args,
**kwargs)
return yaml_dict
@static
def _maybe_include_acknowledgements(yaml_dict):
if "acknowledgements" not in yaml_dict:
yaml_dict["acknowledgements_parsed"] = ""
else:
ack_string = """\
## How to acknowledge the original data set?
Please consider to include the following in the
acknowledgements of any manuscript that uses the data:
> {acknowledgements}
""".format(yaml_dict["acknowledgements"])
yaml_dict["acknowledgements_parsed"] = textwrap.dedent(
ack_string)
return yaml_dict
@static
def _maybe_include_citations(yaml_dict):
if ("citations" not in yaml_dict or
len(yaml_dict["citations"]) == 0):
yaml_dict["citations_parsed"] = ""
else:
cite_string = """\
## How to cite the data set?
The following references provide details about the data
set:
""".format(yaml_dict["citations"])
yaml_dict["citations_parsed"] = textwrap.dedent(
cite_string)
for ct in yaml_dict["citations"]:
yaml_dict["citations_parsed"] += """\
- {text}, doi:{doi}
""".format(ct)
return yaml_dict
def _make_file_executable(file_name):
......
......@@ -25,6 +25,18 @@ repo_description: |
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
asdf asdf asdf asdf asdf asdf
acknowledgement: |
The TEST_REPO data was provided by EXAMPLE.COM.
citations:
- text: Doe, J., J. Doe, A new TEST dataset, J. Alchemy,
doi:12.345/987654asdf11, 2017
doi: 12.345/987654asdf11
- text: Doe, J., J. Doe, An old TEST dataset, J. Alchemy,
doi:12.345/987654asdf10, 2011
doi: 12.345/987654asdf10
prefixes: data doc
pre_processing:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment