Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to monorepo, split into 3 packages #85

Merged
merged 8 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 53 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@ version: 2
references:
setup_env: &setup_env
docker:
- image: circleci/node:8.11.0
- image: circleci/node:lts
save_cache: &save_cache
key: v1-dependency-cache-{{ checksum "yarn.lock" }}
key: v2-dependency-cache-{{ checksum "yarn.lock" }}
paths:
- node_modules
restore_cache: &restore_cache
keys:
- v1-dependency-cache-{{ checksum "yarn.lock" }}
- v1-dependency-cache-
- v2-dependency-cache-{{ checksum "yarn.lock" }}
- v2-dependency-cache-
reports_path: &reports_path
path: ./reports
run_on_tags: &run_on_tags
filters:
# run this job for tags as well
tags:
only: /.*/

jobs:
install-dependencies:
<<: *setup_env
steps:
- checkout
- restore_cache: *restore_cache
- attach_workspace:
at: '.'
- run: yarn --frozen-lockfile
- save_cache: *save_cache
- persist_to_workspace:
root: '.'
paths:
- yarn.lock

build:
<<: *setup_env
steps:
Expand All @@ -31,16 +40,25 @@ jobs:
at: '.'
- run: yarn --frozen-lockfile
- save_cache: *save_cache
- run: mkdir ./reports
- run: yarn compile
- run: yarn lint --format junit --out ./reports/tslint.xml
- run: yarn build
- store_artifacts:
path: dist
- store_test_results: *reports_path
- persist_to_workspace:
root: '.'
paths:
- dist
- packages/*/dist
- packages/*/lib

lint:
<<: *setup_env
steps:
- checkout
- restore_cache: *restore_cache
- attach_workspace:
at: '.'
- run: mkdir -p ./reports
- run: yarn lint -- -- --format junit --out ../../reports/tslint.xml
- store_test_results: *reports_path

test:
<<: *setup_env
Expand All @@ -49,58 +67,57 @@ jobs:
- restore_cache: *restore_cache
- attach_workspace:
at: '.'
- run: mkdir -p ./reports
- run:
command: yarn test --ci --testResultsProcessor="jest-junit"
command: yarn test -- -- --ci --testResultsProcessor="jest-junit"
environment:
JEST_JUNIT_OUTPUT: ./reports/jest.xml
- store_test_results: *reports_path

preview:
deploy-preview:
<<: *setup_env
steps:
- checkout
- restore_cache: *restore_cache
- attach_workspace:
at: '.'
- run: yarn docs
- store_artifacts:
path: docs
path: packages/docs/dist
- run:
name: Submit Github comment with links to built artifacts
command: node theme/bot.js
environment:
# circle-github-bot@0.4.0 expects this env variable
CIRCLE_ARTIFACTS: dopedopedope
command: node scripts/circle-build-preview.js

publish:
deploy-npm:
<<: *setup_env
steps:
- checkout
- restore_cache: *restore_cache
- attach_workspace:
at: '.'
- run: echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
- run: chmod 0600 .npmrc
- run: npm publish
- run: ./scripts/publish-npm-semver-tagged

workflows:
version: 2
build:
build_lint_test_deploy:
jobs:
- build: *run_on_tags
- test: *run_on_tags
- preview:
- install-dependencies
- build:
requires: [install-dependencies]
- lint:
requires: [install-dependencies]
- test:
requires: [build]
- deploy-preview:
requires: [build]
# this job never runs on tags and ignores master
filters:
branches:
ignore: /master/
- publish:
- deploy-npm:
requires: [build, test]
filters:
# run this job only on tags, never on branches
tags:
only: /^release-.*/
branches:
ignore: /.*/

only:
- develop
- next
- /^release\/.*/
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build
dist
node_modules
reports/*.xml
packages/*/lib
packages/*/dist
npm-debug.log
docs.json
theme/version.txt
yarn-error.log
packages/docs/docs.json
packages/docs/theme/version.txt
68 changes: 1 addition & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,4 @@
[![npm](https://img.shields.io/npm/v/documentalist.svg)](https://www.npmjs.com/package/documentalist)
[![CircleCI](https://circleci.com/gh/palantir/documentalist.svg?style=shield&circle-token=1dbd27fe833e64bafb3e8de8ee111a2aee9bb79d)](https://circleci.com/gh/palantir/documentalist)

## Documentalism 101

Documentalism is a two-step process:

1. Get the data.
2. Render the data.

`Documentalist` is an extensible solution to step 1: it helps you get all your data in one place, in a consistent format.
Configure `Documentalist` with plugins to extract documentation data from source files, then feed it a glob of files
and `await` your magical blob of documentation data!

## 1. Get the data

`Documentalist` comes with plugins for the following languages:

- __Markdown__ &mdash; longform documentation and overall structure.
- __TypeScript__ &mdash; JSDoc comments in TypeScript source code.
- __Stylesheets__ &mdash; KSS examples for HTML markup and CSS modifiers.

### Node

Register plugins with `.use(pattern, plugin)`. Supply a `pattern` to match files against; matched files will be compiled by the `plugin`. Documentation data will be collected into a single blob and can be easily written to a file or fed into another tool.

```js
const { Documentalist, MarkdownPlugin, TypescriptPlugin } = require("documentalist");
const { writeFileSync } = require("fs");

new Documentalist()
.use(".md", new MarkdownPlugin())
.use(/\.tsx?$/, new TypescriptPlugin({ excludeNames: [/I.+State$/] }))
.documentGlobs("src/**/*") // ← async operation, returns a Promise
.then(docs => JSON.stringify(docs, null, 2))
.then(json => writeFileSync("docs.json", json))
```

### CLI

On the command line, the Markdown and Typescript plugins are enabled by default.
The CSS plugin can be enabled with `--css`. Plugins can be disabled with the `no-` prefix.

> __Options are not supported__ via the command line interface :sob:.

```sh
documentalist "src/**/*" --css --no-ts > docs.json
```

### Plugins

Documentalist uses a plugin architecture to support arbitrary file types.
Use your own plugins by passing them to `dm.use(pattern, plugin)` with a
pattern to match against source files. The collected matched files will
be passed to your plugin's `compile` function, along with a `compiler`
instance that can be used to render blocks of markdown text.

## 2. Render the data

Now that you've got a sweet data file packed with documentation goodness, what next?

Well, you've got some options. This package does not provide the tools to render the data, but they're fairly easy to construct once you understand the data format.

- Check out the [`theme/`](https://github.com/palantir/documentalist/tree/master/theme) directory here for our simple Pug template that renders the [GitHub Pages site](http://palantir.github.io/documentalist).
- Blueprint publishes a React theme in the [`@blueprintjs/docs-theme`](https://www.npmjs.com/package/@blueprintjs/docs) package (the same one that powers http://blueprintjs.com/docs).

## License

This project is made available under the [BSD License](https://github.com/palantir/documentalist/blob/master/LICENSE)
and includes a [Patent Grant](https://github.com/palantir/documentalist/blob/master/PATENTS).
[See the full usage documentation here](https://palantir.github.io/documentalist/).
Loading