Commit 9af54596 authored by Takuya Noguchi's avatar Takuya Noguchi

Format code blocks in docs

Signed-off-by: default avatarTakuya Noguchi <takninnovationresearch@gmail.com>
parent 22c2ff1a
...@@ -275,7 +275,7 @@ installations from source. ...@@ -275,7 +275,7 @@ installations from source.
It contains the JSON version of the logs in `application.log` like the example below: It contains the JSON version of the logs in `application.log` like the example below:
``` json ```json
{ {
"severity":"INFO", "severity":"INFO",
"time":"2020-01-14T13:35:15.466Z", "time":"2020-01-14T13:35:15.466Z",
......
...@@ -100,7 +100,7 @@ Consider the following pipeline, with jobs `A`, `B`, and `C`. Imagine you want: ...@@ -100,7 +100,7 @@ Consider the following pipeline, with jobs `A`, `B`, and `C`. Imagine you want:
To achieve this, you can configure your `.gitlab-ci.yml` file as follows: To achieve this, you can configure your `.gitlab-ci.yml` file as follows:
``` yaml ```yaml
.only-default: &only-default .only-default: &only-default
only: only:
- main - main
......
...@@ -41,7 +41,7 @@ jobs: ...@@ -41,7 +41,7 @@ jobs:
Example of the same job definition in GitLab CI/CD: Example of the same job definition in GitLab CI/CD:
``` yaml ```yaml
job1: job1:
script: "execute-script-for-job1" script: "execute-script-for-job1"
``` ```
......
...@@ -538,7 +538,7 @@ In this case, we could as well just use `render_ce` which would ignore any EE ...@@ -538,7 +538,7 @@ In this case, we could as well just use `render_ce` which would ignore any EE
partials. One example would be partials. One example would be
`ee/app/views/shared/issuable/form/_default_templates.html.haml`: `ee/app/views/shared/issuable/form/_default_templates.html.haml`:
``` haml ```haml
- if @project.feature_available?(:issuable_default_templates) - if @project.feature_available?(:issuable_default_templates)
= render_ce 'shared/issuable/form/default_templates' = render_ce 'shared/issuable/form/default_templates'
- elsif show_promotions? - elsif show_promotions?
......
...@@ -68,7 +68,7 @@ objects are touching them, then it would be an acceptable use. ...@@ -68,7 +68,7 @@ objects are touching them, then it would be an acceptable use.
We especially allow the case where a single instance variable is used with We especially allow the case where a single instance variable is used with
`||=` to set up the value. This would look like: `||=` to set up the value. This would look like:
``` ruby ```ruby
module M module M
def f def f
@f ||= true @f ||= true
...@@ -85,7 +85,7 @@ we could easily add to the cop, we should do it. ...@@ -85,7 +85,7 @@ we could easily add to the cop, we should do it.
Even if we could just disable the cop, we should avoid doing so. Some code Even if we could just disable the cop, we should avoid doing so. Some code
could be easily rewritten in simple form. Consider this acceptable method: could be easily rewritten in simple form. Consider this acceptable method:
``` ruby ```ruby
module Gitlab module Gitlab
module Emoji module Emoji
def emoji_unicode_version(name) def emoji_unicode_version(name)
...@@ -104,7 +104,7 @@ cop is not smart enough to judge that this is fine. ...@@ -104,7 +104,7 @@ cop is not smart enough to judge that this is fine.
On the other hand, we could split this method into two: On the other hand, we could split this method into two:
``` ruby ```ruby
module Gitlab module Gitlab
module Emoji module Emoji
def emoji_unicode_version(name) def emoji_unicode_version(name)
...@@ -127,7 +127,7 @@ Now the cop doesn't complain. ...@@ -127,7 +127,7 @@ Now the cop doesn't complain.
Put the disabling comment right after your code in the same line: Put the disabling comment right after your code in the same line:
``` ruby ```ruby
module M module M
def violating_method def violating_method
@f + @g # rubocop:disable Gitlab/ModuleWithInstanceVariables @f + @g # rubocop:disable Gitlab/ModuleWithInstanceVariables
...@@ -137,7 +137,7 @@ end ...@@ -137,7 +137,7 @@ end
If there are multiple lines, you could also enable and disable for a section: If there are multiple lines, you could also enable and disable for a section:
``` ruby ```ruby
module M module M
# rubocop:disable Gitlab/ModuleWithInstanceVariables # rubocop:disable Gitlab/ModuleWithInstanceVariables
def violating_method def violating_method
...@@ -167,13 +167,13 @@ point of view), making it extremely hard to track data dependency. ...@@ -167,13 +167,13 @@ point of view), making it extremely hard to track data dependency.
We're trying to use something like this instead: We're trying to use something like this instead:
``` haml ```haml
= render 'projects/commits/commit', commit: commit, ref: ref, project: project = render 'projects/commits/commit', commit: commit, ref: ref, project: project
``` ```
And in the partial: And in the partial:
``` haml ```haml
- ref = local_assigns.fetch(:ref) - ref = local_assigns.fetch(:ref)
- commit = local_assigns.fetch(:commit) - commit = local_assigns.fetch(:commit)
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
......
...@@ -143,7 +143,7 @@ Service classes usually have an `execute` method, which can return a ...@@ -143,7 +143,7 @@ Service classes usually have an `execute` method, which can return a
In a successful case: In a successful case:
``` ruby ```ruby
response = ServiceResponse.success(message: 'Branch was deleted') response = ServiceResponse.success(message: 'Branch was deleted')
response.success? # => true response.success? # => true
...@@ -154,7 +154,7 @@ response.message # => 'Branch was deleted' ...@@ -154,7 +154,7 @@ response.message # => 'Branch was deleted'
In a failed case: In a failed case:
``` ruby ```ruby
response = ServiceResponse.error(message: 'Unsupported operation') response = ServiceResponse.error(message: 'Unsupported operation')
response.success? # => false response.success? # => false
...@@ -165,7 +165,7 @@ response.message # => 'Unsupported operation' ...@@ -165,7 +165,7 @@ response.message # => 'Unsupported operation'
An additional payload can also be attached: An additional payload can also be attached:
``` ruby ```ruby
response = ServiceResponse.success(payload: { issue: issue }) response = ServiceResponse.success(payload: { issue: issue })
response.payload[:issue] # => issue response.payload[:issue] # => issue
......
...@@ -14,7 +14,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/ ...@@ -14,7 +14,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
- Deep merges an array of hashes: - Deep merges an array of hashes:
``` ruby ```ruby
Gitlab::Utils::MergeHash.merge( Gitlab::Utils::MergeHash.merge(
[{ hello: ["world"] }, [{ hello: ["world"] },
{ hello: "Everyone" }, { hello: "Everyone" },
...@@ -25,7 +25,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/ ...@@ -25,7 +25,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
Gives: Gives:
``` ruby ```ruby
[ [
{ {
hello: hello:
...@@ -41,7 +41,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/ ...@@ -41,7 +41,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
- Extracts all keys and values from a hash into an array: - Extracts all keys and values from a hash into an array:
``` ruby ```ruby
Gitlab::Utils::MergeHash.crush( Gitlab::Utils::MergeHash.crush(
{ hello: "world", this: { crushes: ["an entire", "hash"] } } { hello: "world", this: { crushes: ["an entire", "hash"] } }
) )
...@@ -49,7 +49,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/ ...@@ -49,7 +49,7 @@ Refer to [`merge_hash.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/
Gives: Gives:
``` ruby ```ruby
[:hello, "world", :this, :crushes, "an entire", "hash"] [:hello, "world", :this, :crushes, "an entire", "hash"]
``` ```
...@@ -69,7 +69,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi ...@@ -69,7 +69,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi
Here's a simple example: Here's a simple example:
``` ruby ```ruby
class Base class Base
def execute def execute
end end
...@@ -86,7 +86,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi ...@@ -86,7 +86,7 @@ Refer to [`override.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gi
This also works on modules: This also works on modules:
``` ruby ```ruby
module Extension module Extension
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
...@@ -164,7 +164,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/ ...@@ -164,7 +164,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
Instead of writing patterns like this: Instead of writing patterns like this:
``` ruby ```ruby
class Find class Find
def result def result
return @result if defined?(@result) return @result if defined?(@result)
...@@ -176,7 +176,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/ ...@@ -176,7 +176,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
You could write it like: You could write it like:
``` ruby ```ruby
class Find class Find
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
...@@ -190,7 +190,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/ ...@@ -190,7 +190,7 @@ Refer to [`strong_memoize.rb`](https://gitlab.com/gitlab-org/gitlab/blob/master/
- Clear memoization - Clear memoization
``` ruby ```ruby
class Find class Find
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
end end
...@@ -209,7 +209,7 @@ method level values, and optional method arguments. ...@@ -209,7 +209,7 @@ method level values, and optional method arguments.
A simple example that only uses the instance level customised values is: A simple example that only uses the instance level customised values is:
``` ruby ```ruby
class UserAccess class UserAccess
extend Gitlab::Cache::RequestCache extend Gitlab::Cache::RequestCache
...@@ -230,7 +230,7 @@ instance variable so the cache logic would be the same. ...@@ -230,7 +230,7 @@ instance variable so the cache logic would be the same.
We can also set different strategies for different methods: We can also set different strategies for different methods:
``` ruby ```ruby
class Commit class Commit
extend Gitlab::Cache::RequestCache extend Gitlab::Cache::RequestCache
......
...@@ -323,7 +323,7 @@ at the logs that are produced by the container scanning analyzer in `container_s ...@@ -323,7 +323,7 @@ at the logs that are produced by the container scanning analyzer in `container_s
The log contains a list of found vulnerabilities as a table, for example: The log contains a list of found vulnerabilities as a table, for example:
```plainttext ```plaintext
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+ +------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
| STATUS | CVE SEVERITY | PACKAGE NAME | PACKAGE VERSION | CVE DESCRIPTION | | STATUS | CVE SEVERITY | PACKAGE NAME | PACKAGE VERSION | CVE DESCRIPTION |
+------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+ +------------+-------------------------+------------------------+-----------------------+------------------------------------------------------------------------+
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment