Skip to content

Commit 94e5525

Browse files
authored
More docs improvements (#3910)
* Update C call seqs * Prefixing them with self is unusual * Also use `.` instead of `::` to refer to class methods * Capitalize location in docs It allows it to be linked to in docs * Miscelanous other doc tweaks * Format code as code * Nodoc some missed methods * Fix method reference * Really try to nodoc ffi module The previous approach was wrong, to nodoc the class methods it must be specified at the module itself. As a result, the private methods like `dump_options` are also removed. * Remove some def-style comments They are mostly redundant with the method signature and don't look great when rendered. Still remaining on nodes. I will improve docs for them in a separate PR
1 parent 0bd9a7d commit 94e5525

File tree

9 files changed

+172
-179
lines changed

9 files changed

+172
-179
lines changed

config.yml

Lines changed: 89 additions & 88 deletions
Large diffs are not rendered by default.

ext/prism/api_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pack_encoding_to_ruby(pm_pack_encoding encoding) {
173173

174174
/**
175175
* call-seq:
176-
* Pack::parse(version, variant, source) -> Format
176+
* parse(version, variant, source) -> Format
177177
*
178178
* Parse the given source and return a format object.
179179
*/

ext/prism/extension.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,10 @@ dump_input(pm_string_t *input, const pm_options_t *options) {
390390

391391
/**
392392
* call-seq:
393-
* Prism::dump(source, **options) -> String
393+
* dump(source, **options) -> String
394394
*
395395
* Dump the AST corresponding to the given string to a string. For supported
396-
* options, see Prism::parse.
396+
* options, see Prism.parse.
397397
*/
398398
static VALUE
399399
dump(int argc, VALUE *argv, VALUE self) {
@@ -423,10 +423,10 @@ dump(int argc, VALUE *argv, VALUE self) {
423423

424424
/**
425425
* call-seq:
426-
* Prism::dump_file(filepath, **options) -> String
426+
* dump_file(filepath, **options) -> String
427427
*
428428
* Dump the AST corresponding to the given file to a string. For supported
429-
* options, see Prism::parse.
429+
* options, see Prism.parse.
430430
*/
431431
static VALUE
432432
dump_file(int argc, VALUE *argv, VALUE self) {
@@ -795,10 +795,10 @@ parse_lex_input(pm_string_t *input, const pm_options_t *options, bool return_nod
795795

796796
/**
797797
* call-seq:
798-
* Prism::lex(source, **options) -> LexResult
798+
* lex(source, **options) -> LexResult
799799
*
800800
* Return a LexResult instance that contains an array of Token instances
801-
* corresponding to the given string. For supported options, see Prism::parse.
801+
* corresponding to the given string. For supported options, see Prism.parse.
802802
*/
803803
static VALUE
804804
lex(int argc, VALUE *argv, VALUE self) {
@@ -815,10 +815,10 @@ lex(int argc, VALUE *argv, VALUE self) {
815815

816816
/**
817817
* call-seq:
818-
* Prism::lex_file(filepath, **options) -> LexResult
818+
* lex_file(filepath, **options) -> LexResult
819819
*
820820
* Return a LexResult instance that contains an array of Token instances
821-
* corresponding to the given file. For supported options, see Prism::parse.
821+
* corresponding to the given file. For supported options, see Prism.parse.
822822
*/
823823
static VALUE
824824
lex_file(int argc, VALUE *argv, VALUE self) {
@@ -866,7 +866,7 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
866866

867867
/**
868868
* call-seq:
869-
* Prism::parse(source, **options) -> ParseResult
869+
* parse(source, **options) -> ParseResult
870870
*
871871
* Parse the given string and return a ParseResult instance. The options that
872872
* are supported are:
@@ -934,10 +934,10 @@ parse(int argc, VALUE *argv, VALUE self) {
934934

935935
/**
936936
* call-seq:
937-
* Prism::parse_file(filepath, **options) -> ParseResult
937+
* parse_file(filepath, **options) -> ParseResult
938938
*
939939
* Parse the given file and return a ParseResult instance. For supported
940-
* options, see Prism::parse.
940+
* options, see Prism.parse.
941941
*/
942942
static VALUE
943943
parse_file(int argc, VALUE *argv, VALUE self) {
@@ -969,11 +969,11 @@ profile_input(pm_string_t *input, const pm_options_t *options) {
969969

970970
/**
971971
* call-seq:
972-
* Prism::profile(source, **options) -> nil
972+
* profile(source, **options) -> nil
973973
*
974974
* Parse the given string and return nothing. This method is meant to allow
975975
* profilers to avoid the overhead of reifying the AST to Ruby. For supported
976-
* options, see Prism::parse.
976+
* options, see Prism.parse.
977977
*/
978978
static VALUE
979979
profile(int argc, VALUE *argv, VALUE self) {
@@ -990,11 +990,11 @@ profile(int argc, VALUE *argv, VALUE self) {
990990

991991
/**
992992
* call-seq:
993-
* Prism::profile_file(filepath, **options) -> nil
993+
* profile_file(filepath, **options) -> nil
994994
*
995995
* Parse the given file and return nothing. This method is meant to allow
996996
* profilers to avoid the overhead of reifying the AST to Ruby. For supported
997-
* options, see Prism::parse.
997+
* options, see Prism.parse.
998998
*/
999999
static VALUE
10001000
profile_file(int argc, VALUE *argv, VALUE self) {
@@ -1042,10 +1042,10 @@ parse_stream_fgets(char *string, int size, void *stream) {
10421042

10431043
/**
10441044
* call-seq:
1045-
* Prism::parse_stream(stream, **options) -> ParseResult
1045+
* parse_stream(stream, **options) -> ParseResult
10461046
*
10471047
* Parse the given object that responds to `gets` and return a ParseResult
1048-
* instance. The options that are supported are the same as Prism::parse.
1048+
* instance. The options that are supported are the same as Prism.parse.
10491049
*/
10501050
static VALUE
10511051
parse_stream(int argc, VALUE *argv, VALUE self) {
@@ -1095,10 +1095,10 @@ parse_input_comments(pm_string_t *input, const pm_options_t *options) {
10951095

10961096
/**
10971097
* call-seq:
1098-
* Prism::parse_comments(source, **options) -> Array
1098+
* parse_comments(source, **options) -> Array
10991099
*
11001100
* Parse the given string and return an array of Comment objects. For supported
1101-
* options, see Prism::parse.
1101+
* options, see Prism.parse.
11021102
*/
11031103
static VALUE
11041104
parse_comments(int argc, VALUE *argv, VALUE self) {
@@ -1115,10 +1115,10 @@ parse_comments(int argc, VALUE *argv, VALUE self) {
11151115

11161116
/**
11171117
* call-seq:
1118-
* Prism::parse_file_comments(filepath, **options) -> Array
1118+
* parse_file_comments(filepath, **options) -> Array
11191119
*
11201120
* Parse the given file and return an array of Comment objects. For supported
1121-
* options, see Prism::parse.
1121+
* options, see Prism.parse.
11221122
*/
11231123
static VALUE
11241124
parse_file_comments(int argc, VALUE *argv, VALUE self) {
@@ -1137,17 +1137,17 @@ parse_file_comments(int argc, VALUE *argv, VALUE self) {
11371137

11381138
/**
11391139
* call-seq:
1140-
* Prism::parse_lex(source, **options) -> ParseLexResult
1140+
* parse_lex(source, **options) -> ParseLexResult
11411141
*
11421142
* Parse the given string and return a ParseLexResult instance that contains a
11431143
* 2-element array, where the first element is the AST and the second element is
11441144
* an array of Token instances.
11451145
*
11461146
* This API is only meant to be used in the case where you need both the AST and
1147-
* the tokens. If you only need one or the other, use either Prism::parse or
1148-
* Prism::lex.
1147+
* the tokens. If you only need one or the other, use either Prism.parse or
1148+
* Prism.lex.
11491149
*
1150-
* For supported options, see Prism::parse.
1150+
* For supported options, see Prism.parse.
11511151
*/
11521152
static VALUE
11531153
parse_lex(int argc, VALUE *argv, VALUE self) {
@@ -1164,17 +1164,17 @@ parse_lex(int argc, VALUE *argv, VALUE self) {
11641164

11651165
/**
11661166
* call-seq:
1167-
* Prism::parse_lex_file(filepath, **options) -> ParseLexResult
1167+
* parse_lex_file(filepath, **options) -> ParseLexResult
11681168
*
11691169
* Parse the given file and return a ParseLexResult instance that contains a
11701170
* 2-element array, where the first element is the AST and the second element is
11711171
* an array of Token instances.
11721172
*
11731173
* This API is only meant to be used in the case where you need both the AST and
1174-
* the tokens. If you only need one or the other, use either Prism::parse_file
1175-
* or Prism::lex_file.
1174+
* the tokens. If you only need one or the other, use either Prism.parse_file
1175+
* or Prism.lex_file.
11761176
*
1177-
* For supported options, see Prism::parse.
1177+
* For supported options, see Prism.parse.
11781178
*/
11791179
static VALUE
11801180
parse_lex_file(int argc, VALUE *argv, VALUE self) {
@@ -1210,10 +1210,10 @@ parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
12101210

12111211
/**
12121212
* call-seq:
1213-
* Prism::parse_success?(source, **options) -> bool
1213+
* parse_success?(source, **options) -> bool
12141214
*
12151215
* Parse the given string and return true if it parses without errors. For
1216-
* supported options, see Prism::parse.
1216+
* supported options, see Prism.parse.
12171217
*/
12181218
static VALUE
12191219
parse_success_p(int argc, VALUE *argv, VALUE self) {
@@ -1230,10 +1230,10 @@ parse_success_p(int argc, VALUE *argv, VALUE self) {
12301230

12311231
/**
12321232
* call-seq:
1233-
* Prism::parse_failure?(source, **options) -> bool
1233+
* parse_failure?(source, **options) -> bool
12341234
*
12351235
* Parse the given string and return true if it parses with errors. For
1236-
* supported options, see Prism::parse.
1236+
* supported options, see Prism.parse.
12371237
*/
12381238
static VALUE
12391239
parse_failure_p(int argc, VALUE *argv, VALUE self) {
@@ -1242,10 +1242,10 @@ parse_failure_p(int argc, VALUE *argv, VALUE self) {
12421242

12431243
/**
12441244
* call-seq:
1245-
* Prism::parse_file_success?(filepath, **options) -> bool
1245+
* parse_file_success?(filepath, **options) -> bool
12461246
*
12471247
* Parse the given file and return true if it parses without errors. For
1248-
* supported options, see Prism::parse.
1248+
* supported options, see Prism.parse.
12491249
*/
12501250
static VALUE
12511251
parse_file_success_p(int argc, VALUE *argv, VALUE self) {
@@ -1264,10 +1264,10 @@ parse_file_success_p(int argc, VALUE *argv, VALUE self) {
12641264

12651265
/**
12661266
* call-seq:
1267-
* Prism::parse_file_failure?(filepath, **options) -> bool
1267+
* parse_file_failure?(filepath, **options) -> bool
12681268
*
12691269
* Parse the given file and return true if it parses with errors. For
1270-
* supported options, see Prism::parse.
1270+
* supported options, see Prism.parse.
12711271
*/
12721272
static VALUE
12731273
parse_file_failure_p(int argc, VALUE *argv, VALUE self) {
@@ -1298,7 +1298,7 @@ string_query(pm_string_query_t result) {
12981298

12991299
/**
13001300
* call-seq:
1301-
* Prism::StringQuery::local?(string) -> bool
1301+
* local?(string) -> bool
13021302
*
13031303
* Returns true if the string constitutes a valid local variable name. Note that
13041304
* this means the names that can be set through Binding#local_variable_set, not
@@ -1312,7 +1312,7 @@ string_query_local_p(VALUE self, VALUE string) {
13121312

13131313
/**
13141314
* call-seq:
1315-
* Prism::StringQuery::constant?(string) -> bool
1315+
* constant?(string) -> bool
13161316
*
13171317
* Returns true if the string constitutes a valid constant name. Note that this
13181318
* means the names that can be set through Module#const_set, not necessarily the
@@ -1326,7 +1326,7 @@ string_query_constant_p(VALUE self, VALUE string) {
13261326

13271327
/**
13281328
* call-seq:
1329-
* Prism::StringQuery::method_name?(string) -> bool
1329+
* method_name?(string) -> bool
13301330
*
13311331
* Returns true if the string constitutes a valid method name.
13321332
*/

lib/prism.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ def initialize(version)
5656
end
5757

5858
# :call-seq:
59-
# Prism::lex_compat(source, **options) -> LexCompat::Result
59+
# lex_compat(source, **options) -> LexCompat::Result
6060
#
6161
# Returns a parse result whose value is an array of tokens that closely
62-
# resembles the return value of Ripper::lex.
62+
# resembles the return value of Ripper.lex.
6363
#
64-
# For supported options, see Prism::parse.
64+
# For supported options, see Prism.parse.
6565
def self.lex_compat(source, **options)
6666
LexCompat.new(source, **options).result # steep:ignore
6767
end
6868

6969
# :call-seq:
70-
# Prism::load(source, serialized, freeze) -> ParseResult
70+
# load(source, serialized, freeze) -> ParseResult
7171
#
7272
# Load the serialized AST using the source as a reference into a tree.
7373
def self.load(source, serialized, freeze = false)

0 commit comments

Comments
 (0)