From bf033239a706c42be3d7508c58a51c542f8a69b0 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 3 Feb 2020 16:20:38 -0800 Subject: [PATCH] doc update --- docs/parsers/yaml.md | 69 ++++++++++++++++++++++++++++++++++++++++++++ jc/parsers/yaml.py | 20 ++++++++----- 2 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 docs/parsers/yaml.md diff --git a/docs/parsers/yaml.md b/docs/parsers/yaml.md new file mode 100644 index 00000000..adb67658 --- /dev/null +++ b/docs/parsers/yaml.md @@ -0,0 +1,69 @@ +# jc.parsers.yaml +jc - JSON CLI output utility YAML Parser + +Usage: + + specify --yaml as the first argument if the piped input is coming from a YAML file + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd' + +Examples: + + $ cat example.yaml | jc --yaml -p + [ + { + "Description": "This is a YAML document", + "Number": 42 + }, + { + "Description": "Yet Another YAML document" + "Boolean": true + } + ] + +## info +```python +info(self, /, *args, **kwargs) +``` + +## process +```python +process(proc_data) +``` + +Final processing to conform to the schema. + +Parameters: + + proc_data: (dictionary) raw structured data to process + +Returns: + + List of dictionaries. Each dictionary represents a YAML document: + + [ + { + YAML Document converted to a Dictionary + See https://pypi.org/project/ruamel.yaml for details + } + ] + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of dictionaries. Raw or processed structured data. + diff --git a/jc/parsers/yaml.py b/jc/parsers/yaml.py index 53b2d804..4013bb8c 100644 --- a/jc/parsers/yaml.py +++ b/jc/parsers/yaml.py @@ -1,8 +1,8 @@ -"""jc - JSON CLI output utility yaml Parser +"""jc - JSON CLI output utility YAML Parser Usage: - specify --yaml as the first argument if the piped input is coming from a yaml file + specify --yaml as the first argument if the piped input is coming from a YAML file Compatibility: @@ -11,10 +11,16 @@ Compatibility: Examples: $ cat example.yaml | jc --yaml -p - [] - - $ cat example.yaml | jc --yaml -p -r - [] + [ + { + "Description": "This is a YAML document", + "Number": 42 + }, + { + "Description": "Yet Another YAML document" + "Boolean": true + } + ] """ import jc.utils from ruamel.yaml import YAML @@ -22,7 +28,7 @@ from ruamel.yaml import YAML class info(): version = '1.0' - description = 'yaml file parser' + description = 'YAML file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Using the ruamel.yaml library at https://pypi.org/project/ruamel.yaml/'