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

[docs] Set up Danger to warn about updating changed docs on other versions #6890

Merged
merged 5 commits into from Jan 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Expand Up @@ -822,6 +822,10 @@ jobs:
- update_submodules
- yarn_install:
working_directory: docs
- run:
name: Run Danger
working_directory: docs
command: yarn danger ci
- yarn:
command: export
working_directory: docs
Expand Down
52 changes: 52 additions & 0 deletions docs/dangerfile.js
@@ -0,0 +1,52 @@
import { warn } from 'danger';
import fs from 'fs';

function warnIfOnlyOneVersionChanged() {
const LATEST_VERSION = JSON.parse(fs.readFileSync('./package.json')).version;

function getPageName(path) {
let version = getVersionFromPath(path);
return path.replace('docs/pages/versions/', '').replace(`${version}/`, '');
}

function getVersionFromPath(path) {
return path.replace('docs/pages/versions/', '').split('/')[0];
}

let pages = danger.git.modified_files.filter(
file => file.startsWith('docs/pages') && file.endsWith('.md')
);

let groupedByName = pages.reduce((all, path) => {
let pageName = getPageName(path);
all[pageName] = all[pageName] || [];
all[pageName].push(path);
return all;
}, {});

function getSuggestion(version, name) {
if (version === 'unversioned') {
let path = `docs/pages/versions/v${LATEST_VERSION}/${name}`;
let url = `https://github.com/expo/expo/blob/master/${path}`;
return `Please consider copying the changes to the [latest released version](${url}) if applicable.`;
} else if (version === `v${LATEST_VERSION}`) {
let path = `docs/pages/versions/unversioned/${name}`;
let url = `https://github.com/expo/expo/blob/master/${path}`;
return `Please make sure this change won't be lost on the next SDK release by updating the [unversioned copy](${url}).`;
} else {
return `You may also want to make these changes to other versions of the documentation, where applicable, in the [docs/pages/versions](https://github.com/expo/expo/tree/master/docs/pages/versions) directory.`;
}
}

Object.keys(groupedByName).forEach(name => {
let changes = groupedByName[name];
if (changes.length === 1) {
let version = getVersionFromPath(changes[0]);
warn(
`You modified \`${name}\` in the \`${version}\` directory. ${getSuggestion(version, name)}`
);
}
});
}

warnIfOnlyOneVersionChanged();
3 changes: 2 additions & 1 deletion docs/package.json
Expand Up @@ -37,8 +37,9 @@
},
"devDependencies": {
"broken-link-checker": "^0.7.8",
"danger": "^9.2.10",
"http-server": "^0.11.1",
"minimist": "^1.2.0",
"prettier": "^1.18.2"
}
}
}
2 changes: 0 additions & 2 deletions docs/pages/versions/unversioned/sdk/art.md
Expand Up @@ -7,5 +7,3 @@ This library has been removed as of SDK 36. You likely want to use [Svg](../svg/
If you need to use [react-native-progress](https://github.com/oblador/react-native-progress), which relies on ART, you can use the bare workflow and install [`@react-native-community/art`](https://github.com/react-native-community/art), or implement your own progress indicator using Svg ([here's an example](https://github.com/bartgryszko/react-native-circular-progress)).

**Again, you almost definitely want to use [Svg](../svg/) instead of this unless you are really sure you want to use ART for some reason.**

#
4 changes: 1 addition & 3 deletions docs/pages/versions/v36.0.0/sdk/art.md
Expand Up @@ -6,6 +6,4 @@ This library has been removed as of SDK 36. You likely want to use [Svg](../svg/

If you need to use [react-native-progress](https://github.com/oblador/react-native-progress), which relies on ART, you can use the bare workflow and install [`@react-native-community/art`](https://github.com/react-native-community/art), or implement your own progress indicator using Svg ([here's an example](https://github.com/bartgryszko/react-native-circular-progress)).

**Again, you almost definitely want to use [Svg](../svg/) instead of this unless you are really sure you want to use ART for some reason.**

#
**Again, you almost definitely want to use [Svg](../svg/) instead of this unless you are really sure you want to use ART for some reason.**