Skip to content

Commit efed21b

Browse files
authored
Merge pull request #7885 from Marcono1234/marcono1234/extractor-doc-improvements
Fix and improve Extractor options documentation formatting
2 parents 9ebbd9e + 5ec1fc1 commit efed21b

File tree

1 file changed

+51
-43
lines changed

1 file changed

+51
-43
lines changed

docs/codeql/codeql-cli/extractor-options.rst

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,34 @@ setting extractor configuration options through the CodeQL CLI.
1010
About extractor options
1111
-----------------------
1212

13-
Each extractor defines its own set of configuration options. To find out which options are available for a particular extractor, you can run ``codeql resolve languages`` or ``codeql resolve extractor`` with the ``--format=betterjson`` option. The ``betterjson`` output format provides the root paths of extractors and additional information. The output of ``codeql resolve extractor --format=betterjson`` will often be formatted like the following example::
13+
Each extractor defines its own set of configuration options. To find out which options are available for a particular extractor, you can run ``codeql resolve languages`` or ``codeql resolve extractor`` with the ``--format=betterjson`` option. The ``betterjson`` output format provides the root paths of extractors and additional information. The output of ``codeql resolve extractor --format=betterjson`` will often be formatted like the following example:
14+
15+
.. code-block:: json
1416
1517
{
16-
"extractor_root" : "/home/user/codeql/java",
17-
"extractor_options" : {
18-
"option1" : {
19-
"title" : "Java extractor option 1",
20-
"description" : "An example string option for the Java extractor.",
21-
"type" : "string",
22-
"pattern" : "[a-z]+"
23-
},
24-
"group1" : {
25-
"title" : "Java extractor group 1",
26-
"description" : "An example option group for the Java extractor.",
27-
"type" : "object",
28-
"properties" : {
29-
"option2" : {
30-
"title" : "Java extractor option 2",
31-
"description" : "An example array option for the Java extractor",
32-
"type" : "array",
33-
"pattern" : "[1-9][0-9]*"
18+
"extractor_root" : "/home/user/codeql/java",
19+
"extractor_options" : {
20+
"option1" : {
21+
"title" : "Java extractor option 1",
22+
"description" : "An example string option for the Java extractor.",
23+
"type" : "string",
24+
"pattern" : "[a-z]+"
25+
},
26+
"group1" : {
27+
"title" : "Java extractor group 1",
28+
"description" : "An example option group for the Java extractor.",
29+
"type" : "object",
30+
"properties" : {
31+
"option2" : {
32+
"title" : "Java extractor option 2",
33+
"description" : "An example array option for the Java extractor",
34+
"type" : "array",
35+
"pattern" : "[1-9][0-9]*"
36+
}
3437
}
35-
}
36-
}
37-
}
38-
}
38+
}
39+
}
40+
}
3941
4042
The extractor option names and descriptions are listed under ``extractor_options``. Each option may contain the following fields:
4143

@@ -93,27 +95,31 @@ You can also set extractor options through a file. The CodeQL CLI subcommands th
9395

9496
Each option file contains a tree structure of nested maps. At the root is an extractor map key, and beneath it are map keys that correspond to extractor names. Starting at the third level, there are extractor options and option groups.
9597

96-
In JSON::
98+
In JSON:
99+
100+
.. code-block:: json
97101
98102
{
99103
"extractor" : {
100-
java: {
101-
"option1" : abc,
102-
"group1" : {
103-
"option2" : [ 102 ]
104-
}
105-
}
106-
}
107-
}
104+
"java": {
105+
"option1" : "abc",
106+
"group1" : {
107+
"option2" : [ 102 ]
108+
}
109+
}
110+
}
111+
}
108112
109113
110-
In YAML::
114+
In YAML:
115+
116+
.. code-block:: yaml
111117
112118
extractor:
113-
java:
114-
option1: abc
115-
group1:
116-
option2: [ 102 ]
119+
java:
120+
option1: "abc"
121+
group1:
122+
option2: [ 102 ]
117123
118124
The value for a ``string`` extractor option must be a string or a number (which will be converted to a string before further processing).
119125

@@ -123,14 +129,16 @@ The value for an option group (of type ``object``) must be a map, which may cont
123129

124130
Each extractor option value must match the regular expression pattern of the extractor option (if it exists), and it must not contain newline characters.
125131

126-
Assigning an extractor option that does not exist is an error. You can make the CodeQL CLI ignore unknown extractor options by using a special ``__allow_unknown_properties`` Boolean field. For example, the following option file asks the CodeQL CLI to ignore all unknown extractor options and option groups under ``group1``::
132+
Assigning an extractor option that does not exist is an error. You can make the CodeQL CLI ignore unknown extractor options by using a special ``__allow_unknown_properties`` Boolean field. For example, the following option file asks the CodeQL CLI to ignore all unknown extractor options and option groups under ``group1``:
133+
134+
.. code-block:: yaml
127135
128136
extractor:
129-
java:
130-
option1: abc
131-
group1:
132-
__allow_unknown_properties: true
133-
option2: [ 102 ]
137+
java:
138+
option1: "abc"
139+
group1:
140+
__allow_unknown_properties: true
141+
option2: [ 102 ]
134142
135143
You can specify ``--extractor-options-file`` multiple times. The extractor option assignments are processed in the following order:
136144

0 commit comments

Comments
 (0)