diff options
author | Kostis Sagonas <[email protected]> | 2010-02-14 07:32:29 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-02-14 12:23:04 +0100 |
commit | 8b7dd064e2d44b600f05a9135aac08a539a19ffa (patch) | |
tree | fef487ed22331bddc77ecf94d91446653baacef9 /lib/syntax_tools/src/erl_comment_scan.erl | |
parent | 649d313771dc4e53ddfa3ba61504743f38dc8cff (diff) | |
download | otp-8b7dd064e2d44b600f05a9135aac08a539a19ffa.tar.gz otp-8b7dd064e2d44b600f05a9135aac08a539a19ffa.tar.bz2 otp-8b7dd064e2d44b600f05a9135aac08a539a19ffa.zip |
syntax_tools: Add types and specs for most exported functions
While at it, consistently replace "bool()" with "boolean()"
in the Edoc specs.
Diffstat (limited to 'lib/syntax_tools/src/erl_comment_scan.erl')
-rw-r--r-- | lib/syntax_tools/src/erl_comment_scan.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/syntax_tools/src/erl_comment_scan.erl b/lib/syntax_tools/src/erl_comment_scan.erl index 22d6777570..09ce21a428 100644 --- a/lib/syntax_tools/src/erl_comment_scan.erl +++ b/lib/syntax_tools/src/erl_comment_scan.erl @@ -28,6 +28,11 @@ %% ===================================================================== + +-type comment() :: {integer(), integer(), integer(), [string()]}. +-type commentLine() :: {integer(), integer(), integer(), string()}. + +%% ===================================================================== %% @spec file(FileName::file:filename()) -> [Comment] %% %% Comment = {Line, Column, Indentation, Text} @@ -58,6 +63,8 @@ %% error occurred, where `Reason' is an atom corresponding to %% a Posix error code; see the module {@link //kernel/file} for details. +-spec file(file:filename()) -> [comment()]. + file(Name) -> Name1 = filename(Name), case catch {ok, file:read_file(Name1)} of @@ -79,7 +86,7 @@ file(Name) -> %% ===================================================================== -%% string(string()) -> [Comment] +%% @spec string(string()) -> [Comment] %% %% Comment = {Line, Column, Indentation, Text} %% Line = integer() @@ -93,6 +100,8 @@ file(Name) -> %% %% @see file/1 +-spec string(string()) -> [comment()]. + string(Text) -> lists:reverse(join_lines(scan_lines(Text))). @@ -115,6 +124,8 @@ string(Text) -> %% to (but not including) the line-terminating newline. For details on %% `Line', `Column' and `Indent', see {@link file/1}. +-spec scan_lines(string()) -> [commentLine()]. + scan_lines(Text) -> scan_lines(Text, 1, 0, 0, []). @@ -230,6 +241,8 @@ scan_char([], _L, _Col, Ack) -> %% %% @see scan_lines/1 +-spec join_lines([commentLine()]) -> [comment()]. + join_lines([{L, Col, Ind, Txt} | Lines]) -> join_lines(Lines, [Txt], L, Col, Ind); join_lines([]) -> |