[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr b3b6a28d15 68/84: doc: Add more examples
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr b3b6a28d15 68/84: doc: Add more examples |
Date: |
Tue, 3 May 2022 09:58:14 -0400 (EDT) |
branch: externals/tomelr
commit b3b6a28d158845d04f64309f43aab0a9f150c9d1
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
doc: Add more examples
[skip ci]
---
README.org | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/README.org b/README.org
index 6cc67ef18e..6afaf2fb0b 100644
--- a/README.org
+++ b/README.org
@@ -15,6 +15,109 @@ This library started off by extracting the JSON Encoding
pieces from
the Emacs core library
[[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/json.el][*json.el*]].
It was then refactored to meet the specification defined below.
+* API
+This library has only one entry point for simplicity: ~tomelr-encode~.
+
+- Input :: Lisp data expression in Alist or Plist format
+- Ouput :: TOML string
+** Example
+*** Alist data
+#+begin_src emacs-lisp :eval no :noweb-ref data-example-alist
+'((title . "Some Title") ;String
+ (author . ("fn ln")) ;List
+ (description . "some long description\nthat spans multiple\nlines")
;Multi-line string
+ (date . 2022-03-14T01:49:00-04:00) ;RFC 3339 date format
+ (tags . ("tag1" "tag2"))
+ (draft . "false") ;Boolean
+ (versions . ((emacs . "28.1.50") (org . "release_9.5-532-gf6813d"))) ;Map or
TOML Table
+ (org_logbook . (((timestamp . 2022-04-08T14:53:00-04:00) ;Array of maps or
TOML Tables
+ (note . "This note addition prompt shows up on typing the
`C-c C-z` binding.\nSee
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."))
+ ((timestamp . 2018-09-06T11:45:00-04:00)
+ (note . "Another note **bold** _italics_."))
+ ((timestamp . 2018-09-06T11:37:00-04:00)
+ (note . "A note `mono`.")))))
+#+end_src
+
+#+begin_src emacs-lisp :noweb yes :exports none :wrap src toml
+(tomelr-encode
+ <<data-example-alist>>)
+#+end_src
+
+#+RESULTS:
+#+begin_src toml
+title = "Some Title"
+author = [ "fn ln" ]
+description = """
+some long description
+that spans multiple
+lines"""
+date = 2022-03-14T01:49:00-04:00
+tags = [ "tag1", "tag2" ]
+draft = false
+[versions]
+ emacs = "28.1.50"
+ org = "release_9.5-532-gf6813d"
+[[org_logbook]]
+ timestamp = 2022-04-08T14:53:00-04:00
+ note = """
+This note addition prompt shows up on typing the `C-c C-z` binding.
+See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."""
+[[org_logbook]]
+ timestamp = 2018-09-06T11:45:00-04:00
+ note = "Another note **bold** _italics_."
+[[org_logbook]]
+ timestamp = 2018-09-06T11:37:00-04:00
+ note = "A note `mono`."
+#+end_src
+*** Plist data
+#+begin_src emacs-lisp :eval no :noweb-ref data-example-plist
+'(:title "Some Title" ;String
+ :author ("fn ln") ;List
+ :description "some long description\nthat spans multiple\nlines" ;Multi-line
string
+ :date 2022-03-14T01:49:00-04:00 ;RFC 3339 date format
+ :tags ("tag1" "tag2")
+ :draft "false" ;Boolean
+ :versions (:emacs "28.1.50" :org "release_9.5-532-gf6813d") ;Map or TOML
Table
+ :org_logbook ((:timestamp 2022-04-08T14:53:00-04:00 ;Array of maps or TOML
Tables
+ :note "This note addition prompt shows up on typing the `C-c
C-z` binding.\nSee
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers).")
+ (:timestamp 2018-09-06T11:45:00-04:00
+ :note "Another note **bold** _italics_.")
+ (:timestamp 2018-09-06T11:37:00-04:00
+ :note "A note `mono`.")))
+#+end_src
+*** TOML Output
+You will get the below TOML output for either of the above input data.
+#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml
+(tomelr-encode
+ <<data-example-plist>>)
+#+end_src
+
+#+RESULTS:
+#+begin_src toml
+title = "Some Title"
+author = [ "fn ln" ]
+description = """
+some long description
+that spans multiple
+lines"""
+date = 2022-03-14T01:49:00-04:00
+tags = [ "tag1", "tag2" ]
+draft = false
+[versions]
+ emacs = "28.1.50"
+ org = "release_9.5-532-gf6813d"
+[[org_logbook]]
+ timestamp = 2022-04-08T14:53:00-04:00
+ note = """
+This note addition prompt shows up on typing the `C-c C-z` binding.
+See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."""
+[[org_logbook]]
+ timestamp = 2018-09-06T11:45:00-04:00
+ note = "Another note **bold** _italics_."
+[[org_logbook]]
+ timestamp = 2018-09-06T11:37:00-04:00
+ note = "A note `mono`."
+#+end_src
* Limitation
Right now, the scalars and tables/array of tables does not get ordered
in the right order automatically. So the user needs to ensure that the
- [elpa] externals/tomelr ad8366d904 36/84: feat: Support basic TOML Table Arrays, (continued)
- [elpa] externals/tomelr ad8366d904 36/84: feat: Support basic TOML Table Arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 55fefb0fa8 40/84: doc: Add few links, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 38160ef271 41/84: fix: Stricter condition before starting TOML table array check, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a7b3a57037 48/84: feat: Make a very basic nested array of TTA work, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 3aa4dc1dbd 54/84: chore: Add Package-Requires and other info in the header comment, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr f3b6951cfe 53/84: doc: Add note that the scalars need to be earlier in the order, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 192cb06a23 57/84: chore(style): Whitespace change only, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 6d2be83669 69/84: chore: package-lint fixes, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 41ccea4ebe 64/84: refactor: Remove unnecessary tomelr-encode-keyword, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 406f4922a8 58/84: test: Add tests for json.el functions used in tomelr, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b3b6a28d15 68/84: doc: Add more examples,
ELPA Syncer <=
- [elpa] externals/tomelr f9d670e165 56/84: refactor: Clean up unused code, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 511240765b 71/84: chore: Ignore .elc files, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ed13b73e9b 74/84: feat: Support string keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr de661716af 72/84: style: Remove space from after and before [ and ] brackets, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 334b7cba54 76/84: refactor: Don't attempt to triple-quote TOML keys, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c2d1328c44 80/84: fix: Boolean coercing when value is a symbol true or false, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr ebe5959174 75/84: feat: Auto-coerce string to boolean, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a676192b43 81/84: fix: Integer coercing of a number strings with underscores, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 8da825067b 15/84: chore(readme): Update, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 65653d53ee 30/84: chore(doc): M-x checkdoc fixes, ELPA Syncer, 2022/05/03