mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 05:25:34 +02:00
[DOC] Use RDoc inclusions in string.c (#5683)
As @peterzhu2118 and @duerst have pointed out, putting string method's RDoc into doc/ (which allows non-ASCII in examples) makes the "click to toggle source" feature not work for that method. This PR moves the primary method doc back into string.c, then includes RDoc from doc/string/*.rdoc, and also removes doc/string.rdoc. The affected methods are: ::new #bytes #each_byte #each_line #split The call-seq is in string.c because it works there; it did not work when the call-seq is in doc/string/*.rdoc. This PR also updates the relevant guidance in doc/documentation_guide.rdoc.
This commit is contained in:
parent
1fd1f7bbfc
commit
c129b6119d
Notes:
git
2022-03-22 04:58:22 +09:00
Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
8 changed files with 261 additions and 274 deletions
|
@ -60,34 +60,25 @@ involving new files <tt>doc/*.rdoc</tt>:
|
|||
# Documentation for module Bar goes here.
|
||||
module Bar; end
|
||||
|
||||
- For an instance method Baz#bat (defined in file <tt>baz.c</tt>),
|
||||
create file <tt>doc/baz.rdoc</tt>, declare class +Baz+
|
||||
and instance method +bat+, and place the method documentation above
|
||||
the method declaration:
|
||||
- For a method, things are different.
|
||||
Documenting a method as above disables the "click to toggle source" feature
|
||||
in the rendered documentaion.
|
||||
|
||||
# :markup: ruby
|
||||
class Baz
|
||||
# Documentation for method bat goes here.
|
||||
# (Don't forget the call-seq.)
|
||||
def bat; end
|
||||
end
|
||||
Therefore it's best to use file inclusion:
|
||||
|
||||
- For a singleton method Bam.bah (defined in file <tt>bam.c</tt>),
|
||||
create file <tt>doc/bam.rdoc</tt>, declare class +Bam+
|
||||
and singleton method +bah+, and place the method documentation above
|
||||
the method declaration:
|
||||
- Retain the call-seq in the C code.
|
||||
- Use file inclusion (+:include:+) to include text from an .rdoc file.
|
||||
|
||||
# :markup: ruby
|
||||
class Bam
|
||||
# Documentation for method bah goes here.
|
||||
# (Don't forget the call-seq.)
|
||||
def self.bah; end
|
||||
end
|
||||
Example:
|
||||
|
||||
See these examples:
|
||||
|
||||
- https://raw.githubusercontent.com/ruby/ruby/master/doc/string.rdoc
|
||||
- https://raw.githubusercontent.com/ruby/ruby/master/doc/transcode.rdoc
|
||||
/*
|
||||
* call-seq:
|
||||
* each_byte {|byte| ... } -> self
|
||||
* each_byte -> enumerator
|
||||
*
|
||||
* \:include: doc/string/each_byte.rdoc
|
||||
*
|
||||
*/
|
||||
|
||||
=== \RDoc
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue