removes all edoc machinery

This commit is contained in:
alisdair sullivan 2011-03-22 19:02:28 -07:00
parent df674769b9
commit 216a71895a
10 changed files with 2 additions and 484 deletions

View file

@ -21,11 +21,6 @@
%% THE SOFTWARE.
%% @author Alisdair Sullivan <alisdairsullivan@yahoo.ca>
%% @copyright 2010 Alisdair Sullivan
%% @version 0.9.0
%% @doc this module defines the interface to the jsx json parsing library
-module(jsx).
@ -46,142 +41,11 @@
-endif.
%% @type jsx_parser() = (binary()) -> jsx_parser_result().
%% @type jsx_parser_result() = {event, jsx_event(), (() -> jsx_parser_result())}
%% | {incomplete, jsx_parser()}
%% | {error, {badjson, binary()}}
%% | {error, badarg}.
%% @type jsx_event() = start_object
%% | end_object
%% | start_array
%% | end_array
%% | end_json
%% | {key, unicode_string()}
%% | {string, unicode_string()}
%% | {integer, unicode_string()}
%% | {float, unicode_string()}
%% | {literal, true}
%% | {literal, false}
%% | {literal, null}.
%% @type unicode_string() = [integer()].
%% @type jsx_opts() = [jsx_opt()].
%% @type jsx_opt() = {comments, true | false}
%% | {escaped_unicode, ascii | codepoint | none}
%% | {multi_term, true | false}
%% | {unquoted_keys, true | false}
%% | {encoding, auto | supported_utf()}.
%% @type supported_utf() = utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}.
%% @type eep0018() = eep0018_object() | eep0018_array().
%% @type eep0018_array() = [eep0018_term()].
%% @type eep0018_object() = [{eep0018_key(), eep0018_term()}].
%% @type eep0018_key() = binary() | atom().
%% @type eep0018_term() = eep0018_array()
%% | eep0018_object()
%% | eep0018_string()
%% | eep0018_number()
%% | true
%% | false
%% | null.
%% @type eep0018_string() = binary().
%% @type eep0018_number() = float() | integer().
%% @type encoder_opts() = [encoder_opt()].
%% @type encoder_opt() = {strict, true | false}
%% | {encoding, supported_utf()}
%% | {space, integer()}
%% | space
%% | {indent, integer()}
%% | indent.
%% @type decoder_opts() = [decoder_opt()].
%% @type decoder_opt() = {strict, true | false}
%% | {comments, true | false}
%% | {encoding, supported_utf()}
%% | {label, atom | binary | existing_atom}
%% | {float, true | false}.
%% @type verify_opts() = [verify_opt()].
%% @type verify_opt() = {strict, true | false}
%% | {encoding, auto | supported_utf()}
%% | {comments, true | false}.
%% @type format_opts() = [format_opt()].
%% @type format_opt() = {strict, true | false}
%% | {encoding, auto | supported_utf()}
%% | {comments, true | false}
%% | {space, integer()}
%% | space
%% | {indent, integer()}
%% | indent
%% | {output_encoding, supported_utf()}.
%% @spec parser() -> jsx_parser()
%% @equiv parser([])
-spec parser() -> jsx_parser().
parser() ->
parser([]).
%% @spec parser(Opts::jsx_opts()) -> jsx_parser()
%% @doc
%% produces a function which takes a binary which may or may not represent an
%% encoded json document and returns a generator
%%
%% options:
%% <ul>
%% <li>{comments, true | false}
%% <p>if true, json documents that contain c style (/* ... */) comments
%% will be parsed as if they did not contain any comments. default is
%% false</p></li>
%%
%% <li>{encoded_unicode, ascii | codepoint | none}
%% <p>if a \uXXXX escape sequence is encountered within a key or
%% string, this option controls how it is interpreted. none makes no
%% attempt to interpret the value, leaving it unconverted. ascii will
%% convert any value that falls within the ascii range. codepoint will
%% convert any value that is a valid unicode codepoint. note that
%% unicode non-characters (including badly formed surrogates) will
%% never be converted. codepoint is the default</p></li>
%%
%% <li>{encoding, auto
%% | utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>attempt to parse the binary using the specified encoding. auto
%% will auto detect any supported encoding and is the default</p></li>
%%
%% <li>{multi_term, true | false}
%% <p>usually, documents will be parsed in full before the end_json
%% event is emitted. setting this option to true will instead emit
%% the end_json event as soon as a valid document is parsed and then
%% reset the parser to it's initial state and attempt to parse the
%% remainder as a new json document. this allows streams containing
%% multiple documents to be parsed correctly</p></li>
%% </ul>
%% @end
-spec parser(OptsList::jsx_opts()) -> jsx_parser().
@ -194,10 +58,7 @@ parser(OptsList) ->
; {utf32, little} -> jsx_utf32le:parser(OptsList)
; auto -> detect_encoding(OptsList)
end.
%% @spec json_to_term(JSON::binary()) -> eep0018()
%% @equiv json_to_term(JSON, [])
-spec json_to_term(JSON::binary()) -> eep0018().
@ -207,70 +68,13 @@ json_to_term(JSON) ->
catch error:badarg -> erlang:error(badarg)
end.
%% @spec json_to_term(JSON::binary(), Opts::decoder_opts()) -> eep0018()
%% @doc
%% produces an eep0018 representation of a binary encoded json document
%%
%% options:
%% <ul>
%% <li>{strict, true | false}
%% <p>by default, attempting to convert unwrapped json values (numbers,
%% strings and the atoms true, false and null) result in a badarg
%% exception. if strict equals false, these are instead decoded to
%% their equivalent eep0018 value. default is false</p>
%%
%% <p>note that there is a problem of ambiguity when parsing unwrapped
%% json numbers that requires special handling</p>
%%
%% <p>an unwrapped json number has no unambiguous end marker like a
%% json object, array or string. `1', `12' and `123' may all represent
%% either a complete json number or just the beginning of one. in this
%% case, the parser will always return `{incomplete, More}' rather than
%% potentially terminate before input is exhausted. to force
%% termination, `More/1' may be called with the atom `end_stream' as
%% it's argument. note also that numbers followed by whitespace will be
%% parsed correctly</p></li>
%%
%% <li>{encoding, auto
%% | utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>assume the binary is encoded using the specified binary. default
%% is auto, which attempts to autodetect the encoding</p></li>
%%
%% <li>{comments, true | false}
%% <p>if true, json documents that contain c style (/* ... */) comments
%% will be parsed as if they did not contain any comments. default is
%% false</p></li>
%%
%% <li>{label, atom | existing_atom | binary}
%% <p>json keys (labels) are decoded to utf8 encoded binaries, atoms or
%% existing_atoms (atom if it exists, binary otherwise) as specified by
%% this option. default is binary</p></li>
%%
%% <li>{float, true | false}
%% <p>return all numbers as floats. default is false</p></li>
%% </ul>
%% @end
-spec json_to_term(JSON::binary(), Opts::decoder_opts()) -> eep0018().
%json_to_term(JSON, Opts) ->
% try jsx_eep0018:json_to_term(JSON, Opts)
% %% rethrow exception so internals aren't confusingly exposed to users
% catch error:badarg -> erlang:error(badarg)
% end.
json_to_term(JSON, Opts) ->
jsx_eep0018:json_to_term(JSON, Opts).
%% @spec term_to_json(JSON::eep0018()) -> binary()
%% @equiv term_to_json(JSON, [])
-spec term_to_json(JSON::eep0018()) -> binary().
term_to_json(JSON) ->
@ -278,43 +82,7 @@ term_to_json(JSON) ->
%% rethrow exception so internals aren't confusingly exposed to users
catch error:badarg -> erlang:error(badarg)
end.
%% @spec term_to_json(JSON::eep0018(), Opts::encoder_opts()) -> binary()
%% @doc
%% takes the erlang representation of a json object (as defined in eep0018) and
%% returns a (binary encoded) json string
%%
%% options:
%% <ul>
%% <li>{strict, true | false}
%% <p>by default, attempting to convert unwrapped json values (numbers,
%% strings and the atoms true, false and null) result in a badarg
%% exception. if strict equals false, these are instead json encoded.
%% default is false</p></li>
%%
%% <li>{encoding, utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>the encoding of the resulting binary. default is utf8</p></li>
%%
%% <li>space
%% <p>space is equivalent to {space, 1}</p></li>
%%
%% <li>{space, N}
%% <p>place N spaces after each colon and comma in the resulting
%% binary. default is zero</p></li>
%%
%% <li>indent
%% <p>indent is equivalent to {indent, 1}</p></li>
%%
%% <li>{indent, N}
%% <p>indent each 'level' of the json structure by N spaces. default is
%% zero</p></li>
%% </ul>
%% @end
-spec term_to_json(JSON::eep0018(), Opts::encoder_opts()) -> binary().
@ -325,41 +93,11 @@ term_to_json(JSON, Opts) ->
end.
%% @spec is_json(JSON::binary()) -> true | false
%% @equiv is_json(JSON, [])
-spec is_json(JSON::binary()) -> true | false.
is_json(JSON) ->
is_json(JSON, []).
%% @spec is_json(JSON::binary(), verify_opts()) -> true | false
%% @doc
%% returns true if the binary is an encoded json document, false otherwise
%%
%% options:
%% <ul>
%% <li>{strict, true | false}
%% <p>by default, unwrapped json values (numbers, strings and the
%% atoms true, false and null) return false. if strict equals true,
%% is_json returns true. default is false</p></li>
%%
%% <li>{encoding, auto
%% | utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>assume the binary is encoded using the specified binary. default
%% is auto, which attempts to autodetect the encoding</p></li>
%%
%% <li>{comments, true | false}
%% <p>if true, json documents that contain c style (/* ... */) comments
%% will be parsed as if they did not contain any comments. default is
%% false</p></li>
%% </ul>
%% @end
-spec is_json(JSON::binary(), Opts::verify_opts()) -> true | false.
@ -367,75 +105,17 @@ is_json(JSON, Opts) ->
jsx_verify:is_json(JSON, Opts).
%% @spec format(JSON::binary()) -> binary()
%% @equiv format(JSON, [])
-spec format(JSON::binary()) -> binary() | iolist().
format(JSON) ->
format(JSON, []).
%% @spec format(JSON::binary(), Opts::format_opts()) -> binary()
%% @doc
%% formats a binary encoded json string according to the options chose. the
%% defaults will produced a string stripped of all whitespace
%%
%% options:
%% <ul>
%% <li>{strict, true | false}
%% <p>by default, unwrapped json values (numbers, strings and the
%% atoms true, false and null) result in an error. if strict equals
%% true, they are treated as valid json. default is false</p></li>
%%
%% <li>{encoding, auto
%% | utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>assume the binary is encoded using the specified binary. default
%% is auto, which attempts to autodetect the encoding</p></li>
%%
%% <li>{output_encoding, utf8
%% | utf16
%% | {utf16, little}
%% | utf32
%% | {utf32, little}
%% }
%% <p>the encoding of the resulting binary. default is utf8</p></li>
%%
%% <li>{comments, true | false}
%% <p>if true, json documents that contain c style (/* ... */) comments
%% will be parsed as if they did not contain any comments. default is
%% false</p></li>
%%
%% <li>space
%% <p>space is equivalent to {space, 1}</p></li>
%%
%% <li>{space, N}
%% <p>place N spaces after each colon and comma in the resulting
%% binary. default is zero</p></li>
%%
%% <li>indent
%% <p>indent is equivalent to {indent, 1}</p></li>
%%
%% <li>{indent, N}
%% <p>indent each 'level' of the json structure by N spaces. default is
%% zero</p></li>
%% </ul>
%% @end
-spec format(JSON::binary(), Opts::format_opts()) -> binary() | iolist().
format(JSON, Opts) ->
jsx_format:format(JSON, Opts).
%% @spec eventify(List::list()) -> jsx_parser_result()
%% @doc fake the jsx api for any list. useful if you want to serialize a
%% structure to json using the pretty printer, or verify a sequence could be
%% valid json
-spec eventify(List::list()) -> jsx_parser_result().

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_eep0018).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_format).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_utf16).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_utf16le).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_utf32).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_utf32le).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_utf8).

View file

@ -21,9 +21,6 @@
%% THE SOFTWARE.
%% @hidden hide this module from edoc, exported functions are internal to jsx
%% and may be altered or removed without notice
-module(jsx_verify).