docbits
v0.4.1
Published
A single source of truth for documentation, keeping things DRY and maintainable.
Downloads
14
Readme
docbits
A single source of truth for documentation, keeping things DRY and maintainable.
How it works
- Starting in your
-r
or--root
folder, docbits will look for variables in the format${variable-name}
. - For each variable, it will look in your
_bits
folder for a file name that matches the variable name (without the extension).${foo}
will look for a file in_bits
matchingfoo*
, which could be a file namedfoo.md
orfoo.yml
or justfoo
.
- Once found, the variable will be replaced by the exact file contents of the bit. This could be a single word or a multi-line file.
- Finally, the resulting documentation will be written at
-o
or--outputDir
, preserving the existing folder structure.
Installation
npm install --save-dev docbits
Usage
You can run docbits
directly from the CLI or it can be imported and run in code via the API.
CLI
npx docbits --help
API
import { resolveBits, writeResult } from 'docbits'
main()
async function main() {
return writeResult(resolveBits())
}
You don't have to write the result, if you have something else in mind.
async function main() {
for await (const [relativePath, contents] of resolveBits()) {
// do stuff
}
}
This works, because resolveBits
is an async generator function, yielding each relativePath
and contents
as they become available.