Skip to content

Commit

Permalink
Make variables storing default option values public and add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jlumpe committed Jul 9, 2019
1 parent 306fd20 commit dbea5f6
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions ox-json.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

;;; Private constants

(defconst org-json--default-type-exporters
(defconst org-json-default-type-exporters
`(
bool ,#'org-json-encode-bool
string ,#'org-json-encode-string
Expand All @@ -49,9 +49,14 @@
array ,#'org-json-encode-array
plist ,#'org-json-encode-plist
alist ,#'org-json-encode-alist
t ,#'org-json-encode-auto))
t ,#'org-json-encode-auto)
"Plist that stores the default exporter function for element/object
properties by their type symbol.
(defconst org-json--default-property-types
These can be overridden with the :json-exporters option."
)

(defconst org-json-default-property-types
'(
all (
; Never include parent, leads to infinite recursion
Expand Down Expand Up @@ -101,7 +106,18 @@
:scheduled node)
property-drawer (
:properties nil) ; TODO
))
)
"Nested set of plists storing the default type symbols for element/object
properties by element type.
Keys are element/object type symbols as returned by
`org-element-type', along with \"all\" which sets the defaults
for all types. The values are plists mapping property
symbols (starting with colons) to type symbols in
`org-json--default-type-exporters'.
These can be overridden with the :json-property-types option."
)


;;; Variables
Expand Down Expand Up @@ -353,7 +369,7 @@ empty array, false, or null. A null value is arbitrarily returned in this case."
(defun org-json--get-type-encoder (typekey &optional info)
(org-json--plists-get typekey
(plist-get info :json-exporters)
org-json--default-type-exporters))
org-json-default-type-exporters))

(defun org-json-encode-with-type (type value info)
"Encode a VALUE to JSON given its type.
Expand Down Expand Up @@ -502,8 +518,8 @@ Returns a symbol which can be passed to `org-json-encode-with-type'."
(if include-extra t nil)
(plist-get info-types node-type)
(plist-get info-types 'all)
(plist-get org-json--default-property-types node-type)
(plist-get org-json--default-property-types 'all))))
(plist-get org-json-default-property-types node-type)
(plist-get org-jsongdefault-property-types 'all))))

(defun org-json-export-properties-alist (node info)
"Get alist of encoded property values for element/object NODE.
Expand Down

0 comments on commit dbea5f6

Please sign in to comment.