From c059095196b25627482b362dba68df6d498f7ac3 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sun, 6 May 2018 09:34:19 +0200
Subject: [PATCH] docs: refactor packageRules selectors (#1920)

---
 test/website-docs.spec.js             |  15 +++
 website/docs/configuration-options.md | 146 +++++++++++++-------------
 2 files changed, 88 insertions(+), 73 deletions(-)

diff --git a/test/website-docs.spec.js b/test/website-docs.spec.js
index aff8df32a9..9c481cb270 100644
--- a/test/website-docs.spec.js
+++ b/test/website-docs.spec.js
@@ -9,6 +9,7 @@ describe('docs', () => {
   const expectedOptions = options
     .filter(option => option.stage !== 'global')
     .filter(option => !option.admin)
+    .filter(option => !option.parent)
     .map(option => option.name)
     .sort();
   it('has doc headers sorted alphabetically', () => {
@@ -17,4 +18,18 @@ describe('docs', () => {
   it('has headers for every required option', () => {
     expect(headers).toEqual(expectedOptions);
   });
+  const headers3 = doc
+    .match(/\n### (.*?)\n/g)
+    .map(match => match.substring(5, match.length - 1));
+  headers3.sort();
+  const expectedOptions3 = options
+    .filter(option => option.stage !== 'global')
+    .filter(option => !option.admin)
+    .filter(option => option.parent)
+    .map(option => option.name)
+    .sort();
+  expectedOptions3.sort();
+  it('has headers for every required sub-option', () => {
+    expect(headers3).toEqual(expectedOptions3);
+  });
 });
diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md
index f366f882cd..c8cd70e4b4 100644
--- a/website/docs/configuration-options.md
+++ b/website/docs/configuration-options.md
@@ -11,17 +11,6 @@ Also, be sure to check out Renovate's [shareable config presets](./config-preset
 
 If you have any questions about the below config options, or would like to get help/feedback about a config, please post it as an issue in [renovatebot/config-help](https://github.com/renovatebot/config-help) where it will be promptly answered.
 
-## allowedVersions
-
-Use this - usually within a packageRule - to limit how far to upgrade a dependency. For example, if you wish to upgrade to angular v1.5 but not to `angular` v1.6 or higher, you could defined this to be `<= 1.5` or `< 1.6.0`:
-
-```
-  "packageRules": [{
-    "packageNames": ["angular"],
-    "allowedVersions": "<=1.5"
-  }]
-```
-
 ## assignees
 
 Must be valid usernames.
@@ -139,10 +128,6 @@ This is used to alter `commitMessage` and `prTitle` without needing to copy/past
 
 Set to true if repository package.json files contain any local (file) dependencies + lock files. The `package.json` files from each will be copied to disk before lock file generation, even if they are within ignored directories.
 
-## depTypeList
-
-Use this field if you want to limit a `packageRule` to certain `depType` values. Invalid if used outside of a `packageRule`.
-
 ## description
 
 The description field is used by config presets to describe what they do. They are then collated as part of the onboarding description.
@@ -202,34 +187,6 @@ See https://renovateapp.com/docs/deep-dives/private-modules for details on how t
 
 Extend this if you wish to configure rules specifically for `engines` definitions. Currently only `node` is supported.
 
-## excludePackageNames
-
-**Important**: Do not mix this up with the option `ignoreDeps`. Use `ignoreDeps` instead if all you want to do is have a list of package names for Renovate to ignore.
-
-Use `excludePackageNames` if you want to have one or more exact name matches excluded in your package rule. See also `packageNames`.
-
-```
-  "packageRules": [{
-    "packagePatterns": ["^eslint"],
-    "excludePackageNames": ["eslint-foo"]
-  }]
-```
-
-The above will match all package names starting with `eslint` but exclude the specific package `eslint-foo`.
-
-## excludePackagePatterns
-
-Use this field if you want to have one or more package name patterns excluded in your package rule. See also `packagePatterns`.
-
-```
-  "packageRules": [{
-    "packagePatterns": ["^eslint"],
-    "excludePackageNames": ["^eslint-foo"]
-  }]
-```
-
-The above will match all package names starting with `eslint` but exclude ones starting with `eslint-foo`.
-
 ## extends
 
 See https://renovateapp.com/docs/configuration-reference/config-presets for details.
@@ -319,10 +276,6 @@ Add to this object if you wish to define rules that apply only to major updates.
 
 This value defaults to empty string, as historically no prefix was necessary for when Renovate was JS-only. Now - for example - we use `docker-` for Docker branches, so they may look like `renovate/docker-ubuntu-16.x`.
 
-## matchCurrentVersion
-
-`matchCurrentVersion` can be an exact semver version or a semver range.
-
 ## meteor
 
 Set enabled to `true` to enable meteor package updating.
@@ -355,32 +308,6 @@ See https://renovateapp.com/docs/deep-dives/private-modules for details on how t
 
 For settings common to all node.js version updates (e.g. travis, nvm, etc) you can use the `node` object instead.
 
-## packageNames
-
-Use this field if you want to have one or more exact name matches in your package rule. See also `excludedPackageNames`.
-
-```
-  "packageRules": [{
-    "packageNames": ["angular"],
-    "pinVersions": true
-  }]
-```
-
-The above will enable `pinVersions` for the package `angular`.
-
-## packagePatterns
-
-Use this field if you want to have one or more package names patterns in your package rule. See also `excludedPackagePatterns`.
-
-```
-  "packageRules": [{
-    "packageNames": ["^angular"],
-    "pinVersions": false
-  }]
-```
-
-The above will enable `pinVersions` for any package starting with `angular`.
-
 ## packageRules
 
 `packageRules` is a powerful feature that lets you apply rules to individual packages or to groups of packages using regex pattern matching.
@@ -434,6 +361,79 @@ Path rules are convenient to use if you wish to apply configuration rules to cer
   ]
 ```
 
+### allowedVersions
+
+Use this - usually within a packageRule - to limit how far to upgrade a dependency. For example, if you wish to upgrade to angular v1.5 but not to `angular` v1.6 or higher, you could defined this to be `<= 1.5` or `< 1.6.0`:
+
+```
+  "packageRules": [{
+    "packageNames": ["angular"],
+    "allowedVersions": "<=1.5"
+  }]
+```
+
+### depTypeList
+
+Use this field if you want to limit a `packageRule` to certain `depType` values. Invalid if used outside of a `packageRule`.
+
+### excludePackageNames
+
+**Important**: Do not mix this up with the option `ignoreDeps`. Use `ignoreDeps` instead if all you want to do is have a list of package names for Renovate to ignore.
+
+Use `excludePackageNames` if you want to have one or more exact name matches excluded in your package rule. See also `packageNames`.
+
+```
+  "packageRules": [{
+    "packagePatterns": ["^eslint"],
+    "excludePackageNames": ["eslint-foo"]
+  }]
+```
+
+The above will match all package names starting with `eslint` but exclude the specific package `eslint-foo`.
+
+### excludePackagePatterns
+
+Use this field if you want to have one or more package name patterns excluded in your package rule. See also `packagePatterns`.
+
+```
+  "packageRules": [{
+    "packagePatterns": ["^eslint"],
+    "excludePackageNames": ["^eslint-foo"]
+  }]
+```
+
+The above will match all package names starting with `eslint` but exclude ones starting with `eslint-foo`.
+
+### matchCurrentVersion
+
+`matchCurrentVersion` can be an exact semver version or a semver range.
+
+### packageNames
+
+Use this field if you want to have one or more exact name matches in your package rule. See also `excludedPackageNames`.
+
+```
+  "packageRules": [{
+    "packageNames": ["angular"],
+    "pinVersions": true
+  }]
+```
+
+The above will enable `pinVersions` for the package `angular`.
+
+### packagePatterns
+
+Use this field if you want to have one or more package names patterns in your package rule. See also `excludedPackagePatterns`.
+
+```
+  "packageRules": [{
+    "packageNames": ["^angular"],
+    "pinVersions": false
+  }]
+```
+
+The above will enable `pinVersions` for any package starting with `angular`.
+
 ## patch
 
 Add to this object if you wish to define rules that apply only to patch updates. See also `major` and `minor` configuration options.
-- 
GitLab