Improved autodoc documentation for standard ruby methods

and for STL containers, using %feature instead of
hard-coding the stuff in ruby.cxx.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9753 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Gonzalo Garramuno 2007-05-02 20:37:21 +00:00
commit d3945a4d40
7 changed files with 125 additions and 51 deletions

View file

@ -58,6 +58,11 @@
* ------------------------------------------------------------ */
%include <rubykw.swg>
/* ------------------------------------------------------------
* Documentation for common Ruby methods
* ------------------------------------------------------------ */
%include <rubyautodoc.swg>
/* ------------------------------------------------------------
* The Ruby initialization function
* ------------------------------------------------------------ */

54
Lib/ruby/rubyautodoc.swg Normal file
View file

@ -0,0 +1,54 @@
/**
* @file rubyautodoc.swg
* @author gga
* @date Wed May 2 16:41:59 2007
*
* @brief This file implements autodoc typemaps for some common
* ruby methods.
*
*
*/
%define AUTODOC(func, str)
%feature("autodoc", str) func;
%enddef
AUTODOC(to_a, "Convert class to an Array");
AUTODOC(to_s, "Convert class to a String representation");
AUTODOC(inspect, "Inspect class and its contents");
AUTODOC(__getitem__, "Element accessor/slicing");
AUTODOC(__setitem__, "Element setter/slicing");
AUTODOC(operator==, "Equality comparison operator");
AUTODOC(operator<=, "Lower or equal comparison operator");
AUTODOC(operator>=, "Higher or equal comparison operator");
AUTODOC(operator<, "Lower than comparison operator");
AUTODOC(operator>, "Higher than comparison operator");
AUTODOC(operator<<, "Left shifting or appending operator");
AUTODOC(operator>>, "Right shifting operator or extracting operator");
AUTODOC(operator+, "Add operator");
AUTODOC(operator-, "Substraction operator");
AUTODOC(operator+(), "Positive operator");
AUTODOC(operator-(), "Negation operator");
AUTODOC(operator&, "AND operator");
AUTODOC(operator|, "OR operator");
AUTODOC(operator^, "XOR operator");
AUTODOC(operator~, "Invert operator");
AUTODOC(__pow__, "Exponential operator");
AUTODOC(__divmod__, "Modulo of division");
AUTODOC(hash, "Hashing function for class");
AUTODOC(dup, "Create a duplicate of the class and unfreeze it if needed");
AUTODOC(clone, "Create a duplicate of the class");
AUTODOC(coerce, "Coerce class to a number");
AUTODOC(__cmp__, "Comparison operator");
AUTODOC(size, "Size or Length of the container");
AUTODOC(slice, "Return a slice (portion of) the container");
AUTODOC(each, "Iterate thru each element in the container. A block must be provided");
AUTODOC(find, "Find an element in the class or container");
AUTODOC(each_key, "Iterate thru each key element in the container. A block must be provided");
AUTODOC(each_value, "Iterate thru each key element in the container. A block must be provided");
AUTODOC(reject, "Iterate thru each element in the container and reject those that fail a condition returning a new container. A block must be provided");
AUTODOC(reject_bang, "Iterate thru each element in the container and reject those that fail a condition. A block must be provided. Container is modified in place");
AUTODOC(select, "Iterate thru each element in the container and select those that match a condition. A block must be provided");

View file

@ -0,0 +1,28 @@
/**
* @file rubystdautodoc.swg
* @author gga
* @date Wed May 2 17:20:39 2007
*
* @brief This file contains autodocs for standard STL functions.
*
*
*/
//
// For STL autodocumentation
//
AUTODOC(c_str, "Convert class to a String representation");
AUTODOC(begin, "Return an iterator to the beginning of the container");
AUTODOC(end, "Return an iterator to past the end of the container");
AUTODOC(rbegin, "Return a reverse iterator to the beginning (the end) of the container");
AUTODOC(rend, "Return a reverse iterator to past the end (past the beginning) of the container");
AUTODOC(length, "Size or Length of the container");
AUTODOC(resize, "Resize the size of the container");
AUTODOC(capacity, "Reserved capacity of the container");
AUTODOC(reserve, "Reserve memory in the container for a number of elements");
AUTODOC(erase, "Delete a portion of the container");
AUTODOC(max_size, "Maximum size of elements allowed in the container");
AUTODOC(iterator, "Return an iterator to the container");
AUTODOC(empty, "Check if the container is empty or not");
AUTODOC(rfind, "Find an element in reverse usually starting from the end of the container");
AUTODOC(substr, "Return a portion of the String");

View file

@ -203,3 +203,4 @@ namespace swig {
#define SWIG_RUBY_THREAD_BEGIN_BLOCK
#define SWIG_RUBY_THREAD_END_BLOCK

View file

@ -1,5 +1,7 @@
%include <std/std_except.i>
%include <rubystdcommon.swg>
%include <rubystdautodoc.swg>
//
// Use the following macro with modern STL implementations
//

View file

@ -2,5 +2,9 @@
%warnfilter(801) std::string; // wrong class name
%warnfilter(378) std::basic_string::operator!=;
%rename("empty?") std::string::empty;
%rename("empty?") std::basic_string::empty;
%include <typemaps/std_string.swg>