diff --git a/.travis.yml b/.travis.yml index 0022b12da..85809ceee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,12 +21,20 @@ env: - secure: "K1Hf0b0hgRRkIbudmJZCz96ZeObzRJsC4hUZ7N1aolAKkqRcb1HeKkWwD6Ql/kp2shnQ+QQhPVDlvJSDORJ1D+vZlDiYn8fYSjgcXLC1yfkzXkbezLQGZdyTGjpRyyv2vRt1JHtvLIXLrAg4INWyR2mQR/vW8lMdJkVcXnGu+CIdvncnQfYD6axVqWmqCgElEtCOZ3RUxxm2CHSqy7Caf9hF217lxAHORW6QEtfu86WvRoiIX08W9BQpNKvbdafiu0myVTnZUkn+w0ZhTGaS+nTd7AmIbPw8wQsRbm7ex9BTR4PpZMQOE/Aqtm5T7kEbpMK+oXRKIv2Y40YKTDaC27NQl12fZ0ORR6Gttm9DqXXACW8G5F87FkYJUSC8vo8UJFJSJhAKtzsqJRY5rIAr/tSFGwtxhhE4XV2eFC25zaNJsRXhzTyDB+OF9O0EUS2YgEZVfr3cxmUIDimKOsKP918zbjvBtLrZ1KJEs/1yR05J423CZ64T0RzLJ7HATzLt7Wo/nlzij73UglntxZlXWkhmZUGkT/UeNvTE+aPbfam+BWI2Y5v3qrxvtZ9IyOhSIVAsxi+/siRjv256pJnFLgpoGX8hH6rRP0TC3ri+8Sv/xV9ZxiUgUHhOhkUB57Uv1zHEOLR23vMRU1o8y4oA16bckc2SJ3SWrFXKT4qujgI=" stages: + - name: Build + - name: Lint - name: Tests - name: Deployment if: type != pull_request AND branch =~ ^master|3-dev$ jobs: include: + - stage: Lint + name: Lint and check for dead links + language: ruby + script: + - gem install typhoeus + - ruby check_link.rb -p src/ # ------------------------------------------------------------------------- # Snippets tests diff --git a/check_link.rb b/check_link.rb index 28aec268a..820aa6be3 100644 --- a/check_link.rb +++ b/check_link.rb @@ -1,11 +1,29 @@ -require 'byebug' require 'json' require 'uri' require 'typhoeus' require 'optparse' +require 'set' class LinkChecker - INTERNAL_LINK_REGEXP = /\[[\.\w\s\-]+\]\(([\w\/\-\#]*)\)/ + INTERNAL_LINK_REGEXPS = [ + /\[[:\.\w\s\-]+\]\((\/[\w\/\-\#]*)\)/, + // + ] + + IGNORED_EXTERNAL_LINKS = [ + 'http://kuzzle:7512', + 'http://localhost', + 'http://<', + 'http://elasticsearch', + 'http:head', + 'http:options', + 'http:post', + 'http:put', + 'http:get', + 'http:delete', + 'http:patch', + 'http://...' + ] attr_reader :internal, :external @@ -16,8 +34,8 @@ def initialize(options) @hydra = Typhoeus::Hydra.new(max_concurrency: 200) - @internal = [] - @external = {} + @internal = Set.new + @external = Set.new end def run @@ -37,48 +55,54 @@ def run def report_stdout puts "Found #{@internal.count} uniq internal dead links:\n" - puts @internal + puts @internal.to_a puts puts "Found #{@external.count} uniq external dead links:\n" + puts @internal.to_a + puts end def report_json - File.write(@json_file, JSON.pretty_generate({ external: @external, internal: @internal })) + File.write(@json_file, JSON.pretty_generate({ external: @external.to_a, internal: @internal.to_a })) + end + + def exit_code + return 1 if @internal.count > 0 || @external.count > 0 + return 0 end private def scan_internal_links(file_path, content) - match = content.scan(INTERNAL_LINK_REGEXP) - match.each do |(relative_path)| - # Remove anchor - relative_path.gsub!(/#[\w-]+/, '') - - if relative_path.end_with?('.png') - full_path = "src/#{relative_path}" - else - full_path = "src/#{relative_path}/index.md" - end + INTERNAL_LINK_REGEXPS.each do |regexp| + match = content.scan(regexp) + match.each do |(relative_path)| + # Remove anchor + relative_path.gsub!(/#[\w-]+/, '') + + if relative_path.end_with?('/') + full_path = "src/#{relative_path}/index.md" + else + full_path = "src/#{relative_path}" + end - # Remove double // - full_path.gsub!(/\/\//, '/') + # Remove double // + full_path.gsub!(/\/\//, '/') - next if File.exists?(full_path) + next if File.exists?(full_path) - @internal ||= [] - @internal << full_path + @internal << full_path + end end - - @internal.uniq! end def scan_external_links(file_path, content) external_links = URI.extract(content, ['http', 'https']) - external_links.keep_if do |external_link| - !external_link.start_with?('http://kuzzle') && - !external_link.start_with?('http://localhost') && - !external_link.start_with?('http://<') + + external_links.delete_if do |external_link| + external_link.start_with?(*IGNORED_EXTERNAL_LINKS) || + external_link == 'http://' end.each do |external_link| # Remove markdown parenthesis and other garbage external_link.gsub!(/[\)][\.:,]*/, '') @@ -87,8 +111,7 @@ def scan_external_links(file_path, content) request.on_complete do |response| if response.code != 200 - @external[external_link] ||= [] - @external[external_link] << file_path.gsub(/\/\//, '/') + @external << external_link end end @@ -128,3 +151,5 @@ def each_dir(start, &block) link_checker.report_stdout link_checker.report_json + +exit link_checker.exit_code \ No newline at end of file diff --git a/src/core/1/api/essentials/volatile-data/index.md b/src/core/1/api/essentials/volatile-data/index.md index 695c5fd74..228968f52 100644 --- a/src/core/1/api/essentials/volatile-data/index.md +++ b/src/core/1/api/essentials/volatile-data/index.md @@ -77,7 +77,7 @@ There is one special case, where volatile data are stored by Kuzzle for a later Volatile data passed to a new subscription query are used two times by Kuzzle: - if the new subscription triggers [user notifications](/core/1/api/essentials/notifications#user-notification-default), its volatile data are included into those -- if that subscription is cancelled, whether because of a call to [realtime:unsubscribe](/core/1/api/api-reference/controller-realtime/unsubscribe/), or after the user disconnects: the volatile data provided **at the time of the subscription** are once again copied into user notifications triggered by that event +- if that subscription is cancelled, whether because of a call to [realtime:unsubscribe](/core/1/api/controllers/realtime/unsubscribe/), or after the user disconnects: the volatile data provided **at the time of the subscription** are once again copied into user notifications triggered by that event This allows other real-time subscribers to get context information about a user joining or leaving the same subscription as them. diff --git a/src/core/1/guides/cookbooks/elasticsearch/installation/index.md b/src/core/1/guides/cookbooks/elasticsearch/installation/index.md index 9741651c2..3c50f3b6e 100644 --- a/src/core/1/guides/cookbooks/elasticsearch/installation/index.md +++ b/src/core/1/guides/cookbooks/elasticsearch/installation/index.md @@ -10,7 +10,7 @@ order: 100 We want you to work with Elasticsearch while you are reading this cookbook, to do so you will need [cURL](https://curl.haxx.se/download.html), a terminal (Linux, Mac, Cygwin...) -and, optionally, [docker](https://www.docker.com/products/docker) to speed up the installation. +and, optionally, [docker](https://docs.docker.com/install/) to speed up the installation. Alternatively you can simply trust the results we provide in the cookbook and skip the installation chapter. diff --git a/src/core/1/guides/essentials/configuration/index.md b/src/core/1/guides/essentials/configuration/index.md index fba589523..4a373f4c6 100644 --- a/src/core/1/guides/essentials/configuration/index.md +++ b/src/core/1/guides/essentials/configuration/index.md @@ -11,7 +11,7 @@ The Kuzzle **configuration** is stored in a [kuzzlerc file](https://github.com/k Kuzzle uses [rc](https://github.com/dominictarr/rc) to **override** its default configuration by either: -- loading parameters from a `.kuzzlerc` file ([sample file](https://github.com/kuzzleio/kuzzle/blob/master/.kuzzlerc.sample)); +- loading parameters from a `.kuzzlerc` file ([sample file](https://github.com/kuzzleio/kuzzle/blob/master/.kuzzlerc.sample)) ; - loading parameters from environment variables with a `kuzzle_` prefix. ### Example 1: configuring Kuzzle using a custom `.kuzzlerc` file diff --git a/src/core/1/guides/essentials/data-validation/index.md b/src/core/1/guides/essentials/data-validation/index.md index 442411629..25439d9ab 100644 --- a/src/core/1/guides/essentials/data-validation/index.md +++ b/src/core/1/guides/essentials/data-validation/index.md @@ -16,7 +16,7 @@ With Kuzzle, instead of programming the validation logic yourself, you can pick For a detailed look at data validation, please refer to our [Data Validation Reference](/core/1/guides/cookbooks/datavalidation). ::: info -You can bypass data validation by using [bulk:write](/core/1/api/api-reference/bulk-controller/write) or [bulk:mWrite](/core/1/api/api-reference/bulk-controller/m-write) actions. +You can bypass data validation by using [bulk:write](/core/1/api/controllers/bulk/write) or [bulk:mWrite](/core/1/api/controllers/bulk/m-write) actions. ::: --- diff --git a/src/core/1/guides/essentials/installing-kuzzle/index.md b/src/core/1/guides/essentials/installing-kuzzle/index.md index f5be45547..bd2f0358c 100644 --- a/src/core/1/guides/essentials/installing-kuzzle/index.md +++ b/src/core/1/guides/essentials/installing-kuzzle/index.md @@ -93,7 +93,8 @@ Recover the public IP or the hostname provided by AWS before you proceed. Check that Kuzzle is up and running with following HTTP request: ```sh -$ curl 'http://yourInstanceIpOrHostname:7512?pretty' +# Replace kuzzle with your instance hostname or IP +$ curl 'http://kuzzle:7512?pretty' { "requestId": "9b07a095-7143-49a5-9079-a34e937fdf3e", "status": 200, diff --git a/src/core/1/guides/kuzzle-depth/request-life-cycle/index.md b/src/core/1/guides/kuzzle-depth/request-life-cycle/index.md index d5a37273b..efa7eec43 100644 --- a/src/core/1/guides/kuzzle-depth/request-life-cycle/index.md +++ b/src/core/1/guides/kuzzle-depth/request-life-cycle/index.md @@ -36,7 +36,7 @@ The following diagram shows how a request flows between the client application, ![read_scenario_http_details](./Synchronous_Request_HTTP_Protocol_Sequence.png) -- The HTTP client will request a document by making an HTTP GET request. For instance, to retrieve a document with `_id` equal to `739c26bc-7a09-469a-803d-623c4045b0cb` in the `users` collection, the client will perform the following request: `GET http://kuzzlebackend:7512/myindex/users/739c26bc-7a09-469a-803d-623c4045b0cb`. +- The HTTP client will request a document by making an HTTP GET request. For instance, to retrieve a document with `_id` equal to `739c26bc-7a09-469a-803d-623c4045b0cb` in the `users` collection, the client will perform the following request: `GET http://kuzzle:7512/myindex/users/739c26bc-7a09-469a-803d-623c4045b0cb`. - The _Entry Point_ receives the message and passes it on to the _HTTP Router_. diff --git a/src/core/1/plugins/essentials/getting-started/index.md b/src/core/1/plugins/essentials/getting-started/index.md index 860438f2e..d54c69e87 100644 --- a/src/core/1/plugins/essentials/getting-started/index.md +++ b/src/core/1/plugins/essentials/getting-started/index.md @@ -40,7 +40,7 @@ The main Plugin class is defined in the `index.js`. You can start edit it adding We need to provide the `configuration` and the `context` to plugins. In that purpose, plugins must have an `init` function which will have them as parameters : this `init` function is the very first one to be called by Kuzzle and is mandatory to start a plugin. You can now write your own functions and your own routes as described inside the `index.js`. You can also write unit tests : see `steps.js`.
-You can find more information about the init function here. +You can find more information about the init function here.
You have now everything you need to start writing your own Kuzzle plugin. diff --git a/src/core/1/plugins/guides/pipes/index.md b/src/core/1/plugins/guides/pipes/index.md index e2fecaacb..c35402cdb 100644 --- a/src/core/1/plugins/guides/pipes/index.md +++ b/src/core/1/plugins/guides/pipes/index.md @@ -14,7 +14,7 @@ Pipes can: - Decide to abort a task. If a pipe throws an error, Kuzzle interrupts the task, and forwards a standardized version of the thrown error to the originating user - Change the received information. Kuzzle will use the updated information upon resuming the task -
If a pipe takes too long to respond, Kuzzle will eventually abort the entire task with a GatewayTimeout error. The timeout value can be changed in the configuration files.
+
If a pipe takes too long to respond, Kuzzle will eventually abort the entire task with a GatewayTimeout error. The timeout value can be changed in the configuration files.
--- diff --git a/src/core/1/protocols/native-protocols/mqtt/index.md b/src/core/1/protocols/native-protocols/mqtt/index.md index b26e07bfe..5e88ffbd6 100644 --- a/src/core/1/protocols/native-protocols/mqtt/index.md +++ b/src/core/1/protocols/native-protocols/mqtt/index.md @@ -88,7 +88,7 @@ client.on('message', (topic, raw) => { ### Using Kuzzle subscriptions -Kuzzle allows to [subscribe](https://docs.kuzzle.io/core/1/api/controllers/realtime/subscribe/) to messages and events using advanced filters. +Kuzzle allows to [subscribe](/core/1/api/controllers/realtime/subscribe/) to messages and events using advanced filters. Each time a subscription is sent, a dedicated MQTT topic is created, named after the `channel` property issued by Kuzzle. diff --git a/src/sdk/cpp/1/controllers/collection/search-specifications/index.md b/src/sdk/cpp/1/controllers/collection/search-specifications/index.md index 5b6dd08dc..16def14d9 100644 --- a/src/sdk/cpp/1/controllers/collection/search-specifications/index.md +++ b/src/sdk/cpp/1/controllers/collection/search-specifications/index.md @@ -54,7 +54,7 @@ An empty body matches all documents in the queried collection. ## Return -Returns a [kuzzleio::SearchResult](/sdk/cpp/1/search-result). +Returns a [kuzzleio::SearchResult](/sdk/cpp/1/core-classes/search-result). ## Exceptions diff --git a/src/sdk/cpp/1/controllers/document/search/index.md b/src/sdk/cpp/1/controllers/document/search/index.md index 2db2fe28a..a42c3f4a1 100644 --- a/src/sdk/cpp/1/controllers/document/search/index.md +++ b/src/sdk/cpp/1/controllers/document/search/index.md @@ -65,7 +65,7 @@ An empty body matches all documents in the queried collection. ## Return -Returns a [kuzzleio::SearchResult](/sdk/cpp/1/search-result) instance. +Returns a [kuzzleio::SearchResult](/sdk/cpp/1/core-classes/search-result) instance. ## Exceptions diff --git a/src/sdk/java/1/essentials/getting-started/index.md b/src/sdk/java/1/essentials/getting-started/index.md index edb1f0585..91fe76446 100644 --- a/src/sdk/java/1/essentials/getting-started/index.md +++ b/src/sdk/java/1/essentials/getting-started/index.md @@ -120,7 +120,7 @@ Now, you know how to: - Subscribe to notifications ::: info -Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! We're happy to help. +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle) ! We're happy to help. ::: ## Where do we go from here? diff --git a/src/sdk/js/6/getting-started/webpack/index.md b/src/sdk/js/6/getting-started/webpack/index.md index 3cc40ba6b..2bca4901b 100644 --- a/src/sdk/js/6/getting-started/webpack/index.md +++ b/src/sdk/js/6/getting-started/webpack/index.md @@ -13,7 +13,7 @@ We will walk you through creating scripts that can **store** documents in Kuzzle ## Running Kuzzle -Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](https://docs.kuzzle.io/core/1/guides/getting-started/running-kuzzle/) if you don't have one yet. +Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](/core/1/guides/getting-started/running-kuzzle/) if you don't have one yet. ## Fun with the SDK