diff --git a/CHANGES.current b/CHANGES.current index c5347143c..333c5f871 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-05: wsfulton + [Ruby] #538. Fix Ruby support for %feature("docstring"). + 2019-01-03: wsfulton #1202 Fix overloading of non-pointer class types in scripting languages when overloaded with a pointer and a NULL scripting language equivalent is used, eg None in Python. diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 306570d96..08ba4e2b3 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -255,32 +255,22 @@ private: autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } - // If there is more than one line then make docstrings like this: - // - // This is line1 - // And here is line2 followed by the rest of them - // - // otherwise, put it all on a single line - // + + if (have_auto || have_ds) + doc = NewString("/*"); + if (have_auto && have_ds) { // Both autodoc and docstring are present - doc = NewString(""); - Printv(doc, "\n", autodoc, "\n", str, NIL); + Printv(doc, "\n", autodoc, "\n", str, "\n", NIL); } else if (!have_auto && have_ds) { // only docstring - if (Strchr(str, '\n') == 0) { - doc = NewString(str); - } else { - doc = NewString(""); - Printv(doc, str, NIL); - } + Printv(doc, str, NIL); } else if (have_auto && !have_ds) { // only autodoc - if (Strchr(autodoc, '\n') == 0) { - doc = NewStringf("%s", autodoc); - } else { - doc = NewString(""); - Printv(doc, "\n", autodoc, NIL); - } - } else + Printv(doc, "\n", autodoc, "\n", NIL); + } else { doc = NewString(""); + } + + if (have_auto || have_ds) + Append(doc, "*/\n"); // Save the generated strings in the parse tree in case they are used later // by post processing tools @@ -520,7 +510,7 @@ private: last_mode = ad_type; last_autodoc = Copy(methodName); - String *doc = NewString("/*\n"); + String *doc = NewString(""); int counter = 0; bool skipAuto = false; Node* on = n; @@ -760,7 +750,6 @@ private: n = Getattr(n, "sym:nextSibling"); } - Append(doc, "\n*/\n"); Delete(full_name); Delete(class_name); Delete(super_names);