Commit 5953116634660065510fa5892fcc42d0a3c5e725
1 parent
606420ab
Clean up documentation and help around json options
Showing
7 changed files
with
51 additions
and
49 deletions
ChangeLog
| 1 | 2022-01-31 Jay Berkenbilt <ejb@ql.org> | 1 | 2022-01-31 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * Have --json-help just output the JSON object, leaving a | ||
| 4 | + description to --help and the manual. | ||
| 5 | + | ||
| 3 | * Allow optional version number or "latest" as parameter to | 6 | * Allow optional version number or "latest" as parameter to |
| 4 | --json, allowing for future specification of json version. | 7 | --json, allowing for future specification of json version. |
| 5 | 8 |
job.sums
| @@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643 | @@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643 | ||
| 8 | include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 | 8 | include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 |
| 9 | job.yml effc93a805fb74503be2213ad885238db21991ba3d084fbfeff01183c66cb002 | 9 | job.yml effc93a805fb74503be2213ad885238db21991ba3d084fbfeff01183c66cb002 |
| 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 | 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 |
| 11 | -libqpdf/qpdf/auto_job_help.hh 6297d355cb37a6183469962ed75d465d62f498a9a49d43cac7af0c9d013a9e1b | 11 | +libqpdf/qpdf/auto_job_help.hh 6002f503368f319a3d717484ac39d1558f34e67989d442f394791f6f6f5f0500 |
| 12 | libqpdf/qpdf/auto_job_init.hh c244e03e8b83ed7db732920f40aff0134e5f2e78a6edb9473ea4dd1934a8953e | 12 | libqpdf/qpdf/auto_job_init.hh c244e03e8b83ed7db732920f40aff0134e5f2e78a6edb9473ea4dd1934a8953e |
| 13 | libqpdf/qpdf/auto_job_json_decl.hh c5e3fd38a3b0c569eb0c6b4c60953a09cd6bc7d3361a357a81f64fe36af2b0cf | 13 | libqpdf/qpdf/auto_job_json_decl.hh c5e3fd38a3b0c569eb0c6b4c60953a09cd6bc7d3361a357a81f64fe36af2b0cf |
| 14 | libqpdf/qpdf/auto_job_json_init.hh 3f86ce40931ca8f417d050fcd49104d73c1fa4e977ad19d54b372831a8ea17ed | 14 | libqpdf/qpdf/auto_job_json_init.hh 3f86ce40931ca8f417d050fcd49104d73c1fa4e977ad19d54b372831a8ea17ed |
| 15 | -libqpdf/qpdf/auto_job_schema.hh d2fb9344bb0ed9b60cfa5511e81bea1335ea12997df731db9572de46b1d7f0b2 | 15 | +libqpdf/qpdf/auto_job_schema.hh 18a3780671d95224cb9a27dcac627c421cae509d59f33a63e6bda0ab53cce923 |
| 16 | manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 | 16 | manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 |
| 17 | -manual/cli.rst 280826695c13d69527f49ef3e9de89cb628dc55cdbf2ad1dba1606325874c20a | 17 | +manual/cli.rst 35289dbf593085016a62249f760cdcad50d5cce76d799ea4acf5dff58b78679a |
libqpdf/QPDFJob_argv.cc
| @@ -158,28 +158,7 @@ ArgParser::argCopyright() | @@ -158,28 +158,7 @@ ArgParser::argCopyright() | ||
| 158 | void | 158 | void |
| 159 | ArgParser::argJsonHelp() | 159 | ArgParser::argJsonHelp() |
| 160 | { | 160 | { |
| 161 | - // Make sure the output looks right on an 80-column display. | ||
| 162 | - // 1 2 3 4 5 6 7 8 | ||
| 163 | - // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 | ||
| 164 | - std::cout | ||
| 165 | - << "The json block below contains the same structure with the same keys as the" | ||
| 166 | - << std::endl | ||
| 167 | - << "json generated by qpdf. In the block below, the values are descriptions of" | ||
| 168 | - << std::endl | ||
| 169 | - << "the meanings of those entries. The specific contract guaranteed by qpdf in" | ||
| 170 | - << std::endl | ||
| 171 | - << "its json representation is explained in more detail in the manual. You can" | ||
| 172 | - << std::endl | ||
| 173 | - << "specify a subset of top-level keys when you invoke qpdf, but the \"version\"" | ||
| 174 | - << std::endl | ||
| 175 | - << "and \"parameters\" keys will always be present. Note that the \"encrypt\"" | ||
| 176 | - << std::endl | ||
| 177 | - << "key's values will be populated for non-encrypted files. Some values will" | ||
| 178 | - << std::endl | ||
| 179 | - << "be null, and others will have values that apply to unencrypted files." | ||
| 180 | - << std::endl | ||
| 181 | - << QPDFJob::json_out_schema_v1() | ||
| 182 | - << std::endl; | 161 | + std::cout << QPDFJob::json_out_schema_v1() << std::endl; |
| 183 | } | 162 | } |
| 184 | 163 | ||
| 185 | void | 164 | void |
libqpdf/qpdf/auto_job_help.hh
| @@ -30,7 +30,8 @@ ap.addOptionHelp("--replace-input", "usage", "overwrite input with output", R"(U | @@ -30,7 +30,8 @@ ap.addOptionHelp("--replace-input", "usage", "overwrite input with output", R"(U | ||
| 30 | ap.addOptionHelp("--job-json-file", "usage", "job JSON file", R"(--job-json-file=file | 30 | ap.addOptionHelp("--job-json-file", "usage", "job JSON file", R"(--job-json-file=file |
| 31 | 31 | ||
| 32 | Specify the name of a file whose contents are expected to | 32 | Specify the name of a file whose contents are expected to |
| 33 | -contain a QPDFJob json file. | 33 | +contain a QPDFJob JSON file. Run qpdf --job-json-help for a |
| 34 | +description of the JSON input file format. | ||
| 34 | )"); | 35 | )"); |
| 35 | ap.addHelpTopic("exit-status", "meanings of qpdf's exit codes", R"(Meaning of exit codes: | 36 | ap.addHelpTopic("exit-status", "meanings of qpdf's exit codes", R"(Meaning of exit codes: |
| 36 | 37 | ||
| @@ -788,15 +789,18 @@ output as binary data. Get the key with --list-attachments. | @@ -788,15 +789,18 @@ output as binary data. Get the key with --list-attachments. | ||
| 788 | ap.addHelpTopic("json", "JSON output for PDF information", R"(Show information about the PDF file in JSON format. Please see the | 789 | ap.addHelpTopic("json", "JSON output for PDF information", R"(Show information about the PDF file in JSON format. Please see the |
| 789 | JSON chapter in the qpdf manual for details. | 790 | JSON chapter in the qpdf manual for details. |
| 790 | )"); | 791 | )"); |
| 791 | -ap.addOptionHelp("--json", "json", "show file in json format", R"(--json[=version] | 792 | +ap.addOptionHelp("--json", "json", "show file in JSON format", R"(--json[=version] |
| 792 | 793 | ||
| 793 | Generate a JSON representation of the file. This is described in | 794 | Generate a JSON representation of the file. This is described in |
| 794 | depth in the JSON section of the manual. "version" may be a | 795 | depth in the JSON section of the manual. "version" may be a |
| 795 | -specific version or "latest". | 796 | +specific version or "latest". Run qpdf --json-help for a |
| 797 | +description of the generated JSON object. | ||
| 796 | )"); | 798 | )"); |
| 797 | -ap.addOptionHelp("--json-help", "json", "show format of json output", R"(Describe the format of the JSON output. | 799 | +ap.addOptionHelp("--json-help", "json", "show format of JSON output", R"(Describe the format of the JSON output by writing to standard |
| 800 | +output a JSON object with the same keys and with values | ||
| 801 | +containing descriptive text. | ||
| 798 | )"); | 802 | )"); |
| 799 | -ap.addOptionHelp("--json-key", "json", "limit which keys are in json output", R"(--json-key=key | 803 | +ap.addOptionHelp("--json-key", "json", "limit which keys are in JSON output", R"(--json-key=key |
| 800 | 804 | ||
| 801 | This option is repeatable. If given, only the specified | 805 | This option is repeatable. If given, only the specified |
| 802 | top-level keys will be included in the JSON output. Otherwise, | 806 | top-level keys will be included in the JSON output. Otherwise, |
| @@ -808,7 +812,7 @@ This option is repeatable. If given, only specified objects will | @@ -808,7 +812,7 @@ This option is repeatable. If given, only specified objects will | ||
| 808 | be shown in the "objects" key of the JSON output. Otherwise, all | 812 | be shown in the "objects" key of the JSON output. Otherwise, all |
| 809 | objects will be shown. | 813 | objects will be shown. |
| 810 | )"); | 814 | )"); |
| 811 | -ap.addOptionHelp("--job-json-help", "json", "show format of job json", R"(Describe the format of the QPDFJob JSON input. | 815 | +ap.addOptionHelp("--job-json-help", "json", "show format of job JSON", R"(Describe the format of the QPDFJob JSON input. |
| 812 | )"); | 816 | )"); |
| 813 | ap.addHelpTopic("testing", "options for testing or debugging", R"(The options below are useful when writing automated test code that | 817 | ap.addHelpTopic("testing", "options for testing or debugging", R"(The options below are useful when writing automated test code that |
| 814 | includes files created by qpdf or when testing qpdf itself. | 818 | includes files created by qpdf or when testing qpdf itself. |
libqpdf/qpdf/auto_job_schema.hh
| @@ -77,9 +77,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | @@ -77,9 +77,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | ||
| 77 | "withImages": "include image details with showPages", | 77 | "withImages": "include image details with showPages", |
| 78 | "listAttachments": "list embedded files", | 78 | "listAttachments": "list embedded files", |
| 79 | "showAttachment": "export an embedded file", | 79 | "showAttachment": "export an embedded file", |
| 80 | - "json": "show file in json format", | 80 | + "json": "show file in JSON format", |
| 81 | "jsonKey": [ | 81 | "jsonKey": [ |
| 82 | - "limit which keys are in json output" | 82 | + "limit which keys are in JSON output" |
| 83 | ], | 83 | ], |
| 84 | "jsonObject": [ | 84 | "jsonObject": [ |
| 85 | "limit which objects are in JSON" | 85 | "limit which objects are in JSON" |
manual/cli.rst
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | :qpdf:ref:`--option`. They also appear in an index. | 14 | :qpdf:ref:`--option`. They also appear in an index. |
| 15 | 15 | ||
| 16 | Note: 2022-01-22: because short help text is used in the "schema" | 16 | Note: 2022-01-22: because short help text is used in the "schema" |
| 17 | - json object for QPDFJob json, we can't end short text with a ``)`` | 17 | + JSON object for QPDFJob JSON, we can't end short text with a ``)`` |
| 18 | character since doing so would cause ``)"`` to appear in the string | 18 | character since doing so would cause ``)"`` to appear in the string |
| 19 | literal. We use the R"(...)" syntax for these literals, and that | 19 | literal. We use the R"(...)" syntax for these literals, and that |
| 20 | looks like an end delimiter. While the C++ spec allows | 20 | looks like an end delimiter. While the C++ spec allows |
| @@ -163,10 +163,11 @@ Related Options | @@ -163,10 +163,11 @@ Related Options | ||
| 163 | .. help: job JSON file | 163 | .. help: job JSON file |
| 164 | 164 | ||
| 165 | Specify the name of a file whose contents are expected to | 165 | Specify the name of a file whose contents are expected to |
| 166 | - contain a QPDFJob json file. | 166 | + contain a QPDFJob JSON file. Run qpdf --job-json-help for a |
| 167 | + description of the JSON input file format. | ||
| 167 | 168 | ||
| 168 | Specify the name of a file whose contents are expected to contain a | 169 | Specify the name of a file whose contents are expected to contain a |
| 169 | - QPDFJob json file. QXXXQ ref. This file is read and treated as if | 170 | + QPDFJob JSON file. QXXXQ ref. This file is read and treated as if |
| 170 | the equivalent command-line arguments were supplied. It can be | 171 | the equivalent command-line arguments were supplied. It can be |
| 171 | mixed freely with other options. | 172 | mixed freely with other options. |
| 172 | 173 | ||
| @@ -3138,31 +3139,41 @@ Related Options | @@ -3138,31 +3139,41 @@ Related Options | ||
| 3138 | 3139 | ||
| 3139 | .. qpdf:option:: --json[=version] | 3140 | .. qpdf:option:: --json[=version] |
| 3140 | 3141 | ||
| 3141 | - .. help: show file in json format | 3142 | + .. help: show file in JSON format |
| 3142 | 3143 | ||
| 3143 | Generate a JSON representation of the file. This is described in | 3144 | Generate a JSON representation of the file. This is described in |
| 3144 | depth in the JSON section of the manual. "version" may be a | 3145 | depth in the JSON section of the manual. "version" may be a |
| 3145 | - specific version or "latest". | 3146 | + specific version or "latest". Run qpdf --json-help for a |
| 3147 | + description of the generated JSON object. | ||
| 3146 | 3148 | ||
| 3147 | Generate a JSON representation of the file. This is described in | 3149 | Generate a JSON representation of the file. This is described in |
| 3148 | depth in :ref:`json`. The version parameter can be used to specify | 3150 | depth in :ref:`json`. The version parameter can be used to specify |
| 3149 | - which json version should be output. The only supported value is | ||
| 3150 | - ``1``, but it's possible that a new json output version will be | ||
| 3151 | - added in a future version. You can also specify ``latest`` to use | ||
| 3152 | - the latest json version. For backward compatibility, the default | ||
| 3153 | - value is ``1``. | 3151 | + which version of the qpdf JSON format should be output. The only |
| 3152 | + supported value is ``1``, but it's possible that a new JSON output | ||
| 3153 | + version will be added in a future version. You can also specify | ||
| 3154 | + ``latest`` to use the latest JSON version. For backward | ||
| 3155 | + compatibility, the default value is ``1``. Use the | ||
| 3156 | + :qpdf:ref:`--json-help` option to get a description of the JSON | ||
| 3157 | + object. | ||
| 3154 | 3158 | ||
| 3155 | .. qpdf:option:: --json-help | 3159 | .. qpdf:option:: --json-help |
| 3156 | 3160 | ||
| 3157 | - .. help: show format of json output | 3161 | + .. help: show format of JSON output |
| 3158 | 3162 | ||
| 3159 | - Describe the format of the JSON output. | 3163 | + Describe the format of the JSON output by writing to standard |
| 3164 | + output a JSON object with the same keys and with values | ||
| 3165 | + containing descriptive text. | ||
| 3160 | 3166 | ||
| 3161 | - Describe the format of the JSON output. | 3167 | + Describe the format of the JSON output by writing to standard |
| 3168 | + output a JSON object with the same structure with the same keys as | ||
| 3169 | + the JSON generated by qpdf. In the output written by | ||
| 3170 | + ``--json-help``, each key's value is a description of the key. The | ||
| 3171 | + specific contract guaranteed by qpdf in its JSON representation is | ||
| 3172 | + explained in more detail in the :ref:`json`. | ||
| 3162 | 3173 | ||
| 3163 | .. qpdf:option:: --json-key=key | 3174 | .. qpdf:option:: --json-key=key |
| 3164 | 3175 | ||
| 3165 | - .. help: limit which keys are in json output | 3176 | + .. help: limit which keys are in JSON output |
| 3166 | 3177 | ||
| 3167 | This option is repeatable. If given, only the specified | 3178 | This option is repeatable. If given, only the specified |
| 3168 | top-level keys will be included in the JSON output. Otherwise, | 3179 | top-level keys will be included in the JSON output. Otherwise, |
| @@ -3170,7 +3181,8 @@ Related Options | @@ -3170,7 +3181,8 @@ Related Options | ||
| 3170 | 3181 | ||
| 3171 | This option is repeatable. If given, only the specified top-level | 3182 | This option is repeatable. If given, only the specified top-level |
| 3172 | keys will be included in the JSON output. Otherwise, all keys will | 3183 | keys will be included in the JSON output. Otherwise, all keys will |
| 3173 | - be included. | 3184 | + be included. ``version`` and ``parameters`` will always appear in |
| 3185 | + the output. | ||
| 3174 | 3186 | ||
| 3175 | .. qpdf:option:: --json-object={trailer|obj[,gen]} | 3187 | .. qpdf:option:: --json-object={trailer|obj[,gen]} |
| 3176 | 3188 | ||
| @@ -3186,7 +3198,7 @@ Related Options | @@ -3186,7 +3198,7 @@ Related Options | ||
| 3186 | 3198 | ||
| 3187 | .. qpdf:option:: --job-json-help | 3199 | .. qpdf:option:: --job-json-help |
| 3188 | 3200 | ||
| 3189 | - .. help: show format of job json | 3201 | + .. help: show format of job JSON |
| 3190 | 3202 | ||
| 3191 | Describe the format of the QPDFJob JSON input. | 3203 | Describe the format of the QPDFJob JSON input. |
| 3192 | 3204 |
manual/json.rst
| @@ -175,3 +175,7 @@ be aware of: | @@ -175,3 +175,7 @@ be aware of: | ||
| 175 | shown as not filterable by default, but they will be shown as | 175 | shown as not filterable by default, but they will be shown as |
| 176 | filterable if you run :command:`qpdf --json | 176 | filterable if you run :command:`qpdf --json |
| 177 | --decode-level=all`. | 177 | --decode-level=all`. |
| 178 | + | ||
| 179 | +- The ``encrypt`` key's values will be populated for non-encrypted | ||
| 180 | + files. Some values will be null, and others will have values that | ||
| 181 | + apply to unencrypted files. |