Skip to content

Commit 4907c77

Browse files
authored
Chore/documentation improvements (#413)
* chore: implement & document a better release process * chore: changelog generation * Add HISTORY.md * Fix jsdoc for debounce * Add .github_changelog_generator * chore: configure documentation in order to not require manual tweaks, update graph.config.js * docs: consolidate the release process * Change tooltip docs message
1 parent b005d2d commit 4907c77

File tree

8 files changed

+553
-57
lines changed

8 files changed

+553
-57
lines changed

.github_changelog_generator

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
unreleased=true
2+
future-release=2.6.0
3+
since-tag=2.5.0

HISTORY.md

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.

RELEASE_PROCESS.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
## Release Process
1+
# Release Process
22

3-
This is not yet a full automated process, so here are a few steps to get the thing properly released on github and publish under npm registry.
3+
Here are the steps to get the thing properly released on GitHub and published under the npm public registry. There's the need of some manual interventions throughout the release process.
44

5-
### Setup (serve a local version to run tests against it)
5+
## Requirements
66

7-
1. npm run dist:sandbox
8-
2. npm run start (server should keep running in the background as we're going to run
9-
cypress against it)
7+
- Make sure you're able to run `react-d3-graph` locally, follow the `Contributions` steps in the `README.md`.
8+
- Install the [github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator) gem locally. The distribution script will use it to automatically generate a changelog (if possible version >=1.15.2).
9+
- Verify the version: `github_changelog_generator -v`
1010

1111
### Release steps
1212

13-
1. Update versioning in package.json
14-
2. npm run dist
15-
3. npm run docs
16-
4. Small tweaks on documentation page (quicklinks)
17-
5. Replace current files in docs for the generated ones in gen-docs
18-
6. Generate CHANGELOG.md
19-
```bash
20-
github_changelog_generator since-tag=<PREVIOUS_RELEASED_VERSION> -u GITHUB_USERNAME
13+
1. Update versioning in `package.json`, `package-lock.json` and `.github_changelog_generator`.
14+
2. `npm run dist:sandbox` - generates new sandbox assets.
15+
3. `npm run start` - server should keep running in the background as we're going to run
16+
cypress against it.
17+
4. ```bash
18+
# https://github.com/github-changelog-generator/github-changelog-generator#github-token
19+
export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»"
20+
export GITHUB_USERNAME="«your-github-user-name»"
21+
export VERSION_PREV=x.x.x
22+
export VERSION_NEW=x.x.x
23+
24+
npm run dist
2125
```
22-
7. git commit -m "Release x.x.x"
23-
8. Create release x.x.x in github
24-
9. git pull (origin master)
25-
10. npm publish
26+
27+
Please fill in the `VERSION_*` env vars properly to ensure we link documentation during the build process.
28+
29+
5. `git commit -am "Release x.x.x"`.
30+
6. Create the release x.x.x in GitHub. Go to [releases](https://github.com/danielcaldas/react-d3-graph/releases) and click `"Draft a new release"`.
31+
1. Pick a suitable title that highlights some of the most relevant changes.
32+
2. Copy & paste the output of the new CHANGELOG into the release notes.
33+
7. Once you're done on GitHub, go back to you terminal and type `git pull origin master` to pull the latest tag.
34+
8. `npm publish` (see [npm-publish docs](https://docs.npmjs.com/cli/v6/commands/npm-publish) for more details).

documentation.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
toc:
22
- graph.config
33
- Graph
4-
- Graph/renderer
5-
- Graph/builder
6-
- Graph/helper
7-
- Graph/collapse-helper
8-
- Node
9-
- Node/helper
10-
- Link
11-
- Link/helper
12-
- Link/const
13-
- Marker
14-
- Marker/helper
15-
- utils
4+
- name: Internal Documentation
5+
description: |
6+
This section of the documentation is mainly targeted for contributors
7+
working on react-d3-graph. If you're looking into making a change into the codebase
8+
this section could give you an organized overview on the library modules.
9+
children:
10+
- Graph/renderer
11+
- Graph/builder
12+
- Graph/helper
13+
- Graph/collapse-helper
14+
- Node
15+
- Node/helper
16+
- Link
17+
- Link/helper
18+
- Link/const
19+
- Marker
20+
- Marker/helper
21+
- utils

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"dist:rd3g": "rm -rf dist/ && webpack --config webpack.config.dist.js -p --display-modules --optimize-minimize",
1212
"dist:sandbox": "npm run generate:tooltips && webpack --config webpack.config.js -p",
1313
"dist:transpile": "babel -d lib src",
14-
"dist": "npm run check && npm-run-all --parallel dist:*",
14+
"dist:docs": "documentation --config documentation.yml build src/**/*.js -f html -o gen-docs && documentation build src/**/*.js -f md > gen-docs/DOCUMENTATION.md",
15+
"dist": "npm run check && npm-run-all --parallel dist:* && npm run wrapup:dist",
16+
"wrapup:dist": "github_changelog_generator since-tag=$VERSION_PREV -u $GITHUB_USERNAME && mv docs/index.html \"docs/$VERSION_PREV.html\" && mv gen-docs/index.html docs/ && mv gen-docs/DOCUMENTATION.md docs/",
1517
"docs:lint": "documentation lint src/**/*.js",
1618
"docs:watch": "documentation --config documentation.yml build src/**/*.js -f html -o gen-docs --watch",
17-
"docs": "npm run docs:lint && documentation --config documentation.yml build src/**/*.js -f html -o gen-docs && documentation build src/**/*.js -f md > gen-docs/DOCUMENTATION.md",
1819
"functional:local": "cross-env CYPRESS_SANDBOX_URL=\"http://localhost:3002\" cypress open",
1920
"functional:remote": "cross-env CYPRESS_SANDBOX_URL=\"https://danielcaldas.github.io/react-d3-graph/sandbox/index.html\" cypress open",
2021
"functional": "cross-env CYPRESS_SANDBOX_URL=\"http://127.0.0.1:8888\" cypress run",

src/components/graph/graph.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
/**
22
* <div style="text-align: right;"><i>This is certainly the only extra piece of documentation that you will ever need</i></div>
33
* </br></br>
4+
*
5+
* <b>Links</b></br>
6+
* <ul>
7+
* <li><a href="https://danielcaldas.github.io/react-d3-graph/sandbox/index.html" target="_blank" title="react-d3-graph live demo">🔗 Live Demo</a></li>
8+
* <li><a href="https://github.com/danielcaldas/react-d3-graph" target="_blank" title="react-d3-graph repository">🔗 GitHub</a></li>
9+
* </ul>
10+
*
411
* Here you can consult a detailed description of each graph configurable property as well as the default values
512
* of those properties.
613
*
@@ -102,7 +109,7 @@
102109
* - If value is negative, nodes will repel each other. Most of the times this is what we want, so nodes don"t overlap.
103110
* @param {number} [d3.linkLength=100] - <a id="d3-link-length" href="#d3-link-length">🔗</a> the length of each link from the center of the nodes it joins.
104111
* @param {number} [d3.linkStrength=1] - <a id="d3-link-strength" href="#d3-link-strength">🔗</a> <a target="_blank" href="https://github.com/d3/d3-force#link_strength">see d3-force link.strength</a>
105-
* @param {boolean} [d3.disableLinkForce=false] - <a id="d3-disable-link-force" href="#d3-disable-link-force">🔗</a> ⚠️🧪EXPERIMENTAL🧪⚠️ it completely disables d3 force link and simulation to re-trigger so that one can obtain
112+
* @param {boolean} [d3.disableLinkForce=false] - <a id="d3-disable-link-force" href="#d3-disable-link-force">🔗</a> Completely disables d3 force link and simulation to re-trigger so that one can obtain
106113
* precise render of node positions as described by the author <a target="_blank" href="https://github.com/antoninklopp">@antoninklopp</a> in <a target="_blank" href="https://github.com/danielcaldas/react-d3-graph/pull/278">the Pull Request description</a>.
107114
* </br>
108115
* @param {Object} node node object is explained in next section. ⬇️
@@ -213,7 +220,7 @@
213220
* property for when link is mouse hovered.
214221
* @param {number} [link.opacity=1] 🔍 - <a href="#link-opacity" href="">🔗</a> the default opacity value for links.
215222
* @param {boolean} [link.renderLabel=false] - <a id="link-render-label" href="#link-render-label">🔗</a> when set to true labels will appear along side links in the
216-
* graph. <b>Note</b>: this will only happen of course if proper label is passed within the link, check also <code>link.labelProperty</code>.
223+
* graph. <b>Note:</b> this will only happen of course if proper label is passed within the link, check also <code>link.labelProperty</code>.
217224
* </br>
218225
* <img src="https://github.com/danielcaldas/react-d3-graph/blob/master/docs/rd3g-link-render-label.png?raw=true" width="820" height="480"/>
219226
* @param {boolean} [link.semanticStrokeWidth=false] - <a id="link-semantic-stroke-width" href="#link-semantic-stroke-width">🔗</a> when set to true all links will have

src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ function antiPick(o, props = []) {
177177
* @param {function} fn Function to debounce
178178
* @param {number} time Milliseconds to wait before invoking the function if it is called repeatedly
179179
* @returns {function} Version of function that will only be called every `time` milliseconds
180+
* @memberof utils
180181
*/
181182
function debounce(fn, time) {
182183
let timer;

tools/tooltips-docs-generator.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const TOOLTIPS_MAX_WIDTH = 400;
33
const LIVE_DOCS_LINK = "https://danielcaldas.github.io/react-d3-graph/docs/index.html";
44

55
if (!data || !data.length || !data[0].params) {
6-
throw new Error("Invalid JSON provided from jsdoc parser");
6+
throw new Error("Invalid JSON provided from jsdoc parser");
77
}
88

99
/**
@@ -12,12 +12,12 @@ if (!data || !data.length || !data[0].params) {
1212
* @returns {string} new string which results on converting input string to kebab case.
1313
*/
1414
function strToKebabCase(s) {
15-
const _s = s.replace(".", "-"); // drop all the '.' dots
15+
const _s = s.replace(".", "-"); // drop all the '.' dots
1616

17-
return _s
18-
.replace(/([a-z])([A-Z])/g, "$1-$2")
19-
.replace(/\s+/g, "-")
20-
.toLowerCase();
17+
return _s
18+
.replace(/([a-z])([A-Z])/g, "$1-$2")
19+
.replace(/\s+/g, "-")
20+
.toLowerCase();
2121
}
2222

2323
/**
@@ -27,9 +27,9 @@ function strToKebabCase(s) {
2727
* official documentation website.
2828
*/
2929
function generatePropertyAnchorLink(name) {
30-
const suffix = strToKebabCase(name);
30+
const suffix = strToKebabCase(name);
3131

32-
return `${LIVE_DOCS_LINK}#${suffix}`;
32+
return `${LIVE_DOCS_LINK}#${suffix}`;
3333
}
3434

3535
/**
@@ -38,11 +38,11 @@ function generatePropertyAnchorLink(name) {
3838
* @returns {string} the footer for the given property.
3939
*/
4040
function generateCommonFooter(name) {
41-
const href = generatePropertyAnchorLink(name);
41+
const href = generatePropertyAnchorLink(name);
4242

43-
return `\
43+
return `\
4444
<small>\
45-
for more details check the <a target="_blank" href="${href}">official documentation</a>\
45+
<a target="_blank" href="${href}">see full official documentation</a>\
4646
</small>\
4747
`;
4848
}
@@ -68,25 +68,25 @@ function generateCommonFooter(name) {
6868
* information mapped by the param name.
6969
*/
7070
function getParamInfo(param) {
71-
const { type, optional, defaultvalue, description: rawDescription, name } = param;
72-
const types = type && type.names && type.names;
73-
const ftype = types && types.length ? types.join("|") : "*";
71+
const { type, optional, defaultvalue, description: rawDescription, name } = param;
72+
const types = type && type.names && type.names;
73+
const ftype = types && types.length ? types.join("|") : "*";
7474

75-
// make images smaller so that they fit in the tooltip
76-
const description = rawDescription
77-
.replace(/width="(\d+)"/gi, "width='400'")
78-
.replace(/height="(\d+)"/gi, "height='200'")
79-
.replace("🔗", ""); // drop docs anchor links
75+
// make images smaller so that they fit in the tooltip
76+
const description = rawDescription
77+
.replace(/width="(\d+)"/gi, "width='400'")
78+
.replace(/height="(\d+)"/gi, "height='200'")
79+
.replace("🔗", ""); // drop docs anchor links
8080

81-
return {
82-
[name]: `\
81+
return {
82+
[name]: `\
8383
<h4>${name}</h4>\
8484
<b>type</b>: ${ftype} | <b>default value</b>: ${defaultvalue} | <b>optional</b>: ${optional}\
8585
<h5>Description</h5>\
8686
<div style="max-width: ${TOOLTIPS_MAX_WIDTH}px;">${description}</div>\
8787
${generateCommonFooter(name)}\
8888
`,
89-
};
89+
};
9090
}
9191

9292
/**
@@ -96,7 +96,7 @@ function getParamInfo(param) {
9696
* @returns {string} final text without javascript code blocks.
9797
*/
9898
function stripJsMdBlocks(s) {
99-
return s.replace(/```javascript(.*)```/gi, "");
99+
return s.replace(/```javascript(.*)```/gi, "");
100100
}
101101

102102
const graphConfigElms = data[0].params.map(getParamInfo).reduce((acc, o) => ({ ...o, ...acc }), {});

0 commit comments

Comments
 (0)