From 79fce8c769525aa6738222d579fde1afcbecc6c1 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 27 Feb 2023 17:37:49 -0800 Subject: [PATCH] doc update --- docs/parsers/proc_pid_smaps.md | 3 +- docs/parsers/semver.md | 2 + docs/parsers/ver.md | 112 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 docs/parsers/ver.md diff --git a/docs/parsers/proc_pid_smaps.md b/docs/parsers/proc_pid_smaps.md index 974d82f9..f9cff94e 100644 --- a/docs/parsers/proc_pid_smaps.md +++ b/docs/parsers/proc_pid_smaps.md @@ -114,7 +114,8 @@ Examples: "mw", "me", "dw", - "sd" + "sd", + "mp" ], "VmFlags_pretty": [ "readable", diff --git a/docs/parsers/semver.md b/docs/parsers/semver.md index 64ba7373..ed73a1fd 100644 --- a/docs/parsers/semver.md +++ b/docs/parsers/semver.md @@ -7,6 +7,8 @@ jc - JSON Convert Semantic Version string parser This parser conforms to the specification at https://semver.org/ +See Also: `ver` parser. + Usage (cli): $ echo 1.2.3-rc.1+44837 | jc --semver diff --git a/docs/parsers/ver.md b/docs/parsers/ver.md new file mode 100644 index 00000000..8bdee50e --- /dev/null +++ b/docs/parsers/ver.md @@ -0,0 +1,112 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.ver + +jc - JSON Convert Version string output parser + +Best-effort attempt to parse various styles of version numbers. This parser +is based off of the version parser included in the CPython distutils +libary. + +If the version string conforms to some de facto-standard versioning rules +followed by many developers a `strict` key will be present in the output +with a value of `true` along with the named parsed components. + +All other version strings will have a `strict` value of `false` and a +`components` key will contain a list of detected parts of the version +string. + +See Also: `semver` parser. + +Usage (cli): + + $ echo 1.2a1 | jc --ver + +Usage (module): + + import jc + result = jc.parse('ver', version_string_output) + +Schema: + + { + "major": integer, + "minor": integer, + "patch": integer, + "prerelease": string, + "prerelease_num": integer, + "components": [ + integer/string + ], + "strict": boolean + } + +Examples: + + $ echo 1.2a1 | jc --ver -p + { + "major": 1, + "minor": 2, + "patch": 0, + "prerelease": "a", + "prerelease_num": 1, + "strict": true + } + + $ echo 1.2a1 | jc --ver -p -r + { + "major": "1", + "minor": "2", + "patch": "0", + "prerelease": "a", + "prerelease_num": "1", + "strict": true + } + + $ echo 1.2beta3 | jc --ver -p + { + "components": [ + 1, + 2, + "beta", + 3 + ], + "strict": false + } + + $ echo 1.2beta3 | jc --ver -p -r + { + "components": [ + "1", + "2", + "beta", + "3" + ], + "strict": false + } + + + +### parse + +```python +def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of Dictionaries. Raw or processed structured data. + +### Parser Information +Compatibility: linux, darwin, cygwin, win32, aix, freebsd + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)