0.0.2 • Published 4 years ago
@retrogen/templates v0.0.2
@retrogen/templates
Templates to convert data from @retrogen/core into human-readable markdown.
Note: If you want to use these templates without having to write your own scripts, you'll want to take a look at
@retrogen/generate
Usage
Basic example:
// source: ./examples/default.js
const templates = require('@retrogen/templates')
const data = require('./data/example.json') // assuming you've got generated data in a file
async function useTemplate () {
// use our basic template with the imported data
const result = await templates('basic', data)
// output the result
console.log(result)
}
useTemplate()An example with data from @retrogen/core:
// source: ./examples/usingCore.js
const templates = require('@retrogen/templates')
const core = require('@retogen/core')
const { DateTime } = require('luxon')
async function useTemplate () {
// set up relative dates
const now = DateTime.now()
const then = now.minus({ days: 7 })
// convert them to usable ISO dates
const dates = {
start: then.toISODate(),
end: now.toISODate()
}
// fetch and format our data from GitHub
const data = await core('nodejs', dates)
// use our basic template with the generated/formatted data
const result = await templates('basic', data)
// output the result
console.log(result)
}
useTemplate()Addtional examples can be found in ./examples/.
API
Assuming you've required this module as templates:
templates(template, data, options)templateString (required) - Valid values:basic: a basic template.- That's all for now. If you'd like to see another template, PRs are welcome.
dataObject (required):- This has to be output from
@retrogen/core.
- This has to be output from
optionsObject (optional):headingString (optional): the heading to use for the output Markdown.- Default:
# Retrospective for ${data.meta.owner}.
- Default:
prefaceString (optional): the preface to use for the output Markdown.- Default:
Reporting on ${data.meta.issues.count} Issues from ${data.meta.issues.authors.count} authors, ${data.meta.pullRequests.count} Pull Requests from ${data.meta.pullRequests.authors.count} authors, and ${data.meta.discussions.count} Discussions from ${data.meta.discussions.authors.count} authors..
- Default:
includeDatesInHeadingsBoolean (optional): Boolean that tells the template whether to include the dates in the headings if bothoptions.startandoptions.endhave non-undefined values.- Default:
false.
- Default:
startString (optional): Start date of the range passed, in the format ofYYYY-MM-DD.endString (Optional): End date of the range passed, in the format ofYYYY-MM-DD.
The goal with these API docs is to have a consistent style of documentation for each module in the monorepo. If there's inconsistencies, please feel free to open an issue to let the maintainers know.