zmike pushed a commit to branch efl-1.22.

http://git.enlightenment.org/core/efl.git/commit/?id=e8edd7710e858b9ad8439f572d3a84f7f3218a6d

commit e8edd7710e858b9ad8439f572d3a84f7f3218a6d
Author: Xavi Artigas <[email protected]>
Date:   Thu Apr 11 10:37:33 2019 +0200

    efl-mono: Allow doc XML tags to be nested
    
    Summary:
    This allows inserting nested tags like:
    <example><code>bla bla bla</code></example>
    
    The generate_tag_example() is currently unused but serves as an example.
    
    Depends on D8585
    
    Test Plan:
    Not much, unless you want to manually call generate_tag_example()
    (Which I have done, and it works, I promise).
    
    Reviewers: lauromoura, vitor.sousa
    
    Reviewed By: vitor.sousa
    
    Subscribers: vitor.sousa, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D8587
---
 src/bin/eolian_mono/eolian/mono/documentation.hh | 40 ++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh 
b/src/bin/eolian_mono/eolian/mono/documentation.hh
index e7666a922c..c46cbd4231 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -244,7 +244,19 @@ struct documentation_generator
 
    /// Tag generator helpers
    template<typename OutputIterator, typename Context>
-   bool generate_tag(OutputIterator sink, std::string const& tag, std::string 
const &text, Context const& context, std::string tag_params = "") const
+   bool generate_opening_tag(OutputIterator sink, std::string const& tag, 
Context const& context, std::string tag_params = "") const
+   {
+      return as_generator("<" << tag << tag_params << ">").generate(sink, 
attributes::unused, context);
+   }
+
+   template<typename OutputIterator, typename Context>
+   bool generate_closing_tag(OutputIterator sink, std::string const& tag, 
Context const& context) const
+   {
+      return as_generator("</" << tag << ">").generate(sink, 
attributes::unused, context);
+   }
+
+   template<typename OutputIterator, typename Context>
+   bool generate_escaped_content(OutputIterator sink, std::string const &text, 
Context const& context) const
    {
       std::string new_text;
       if 
(!as_generator(html_escaped_string).generate(std::back_inserter(new_text), 
text, context))
@@ -256,14 +268,24 @@ struct documentation_generator
 
       std::istringstream ss(new_text);
       std::string para;
-      std::string final_text = "<" + tag + tag_params + ">";
+      std::string final_text;
       bool first = true;
       while (std::getline(ss, para)) {
         if (first) final_text += para;
         else final_text += "\n" + tabs + para;
         first = false;
       }
-      return as_generator(scope_tab(scope_size) << "/// " << final_text << 
"</" << tag << ">\n").generate(sink, attributes::unused, context);
+      return as_generator(final_text).generate(sink, attributes::unused, 
context);
+   }
+
+   template<typename OutputIterator, typename Context>
+   bool generate_tag(OutputIterator sink, std::string const& tag, std::string 
const &text, Context const& context, std::string tag_params = "") const
+   {
+      if (!as_generator(scope_tab(scope_size) << "/// ").generate(sink, 
attributes::unused, context)) return false;
+      if (!generate_opening_tag(sink, tag, context, tag_params)) return false;
+      if (!generate_escaped_content(sink, text, context)) return false;
+      if (!generate_closing_tag(sink, tag, context)) return false;
+      return as_generator("\n").generate(sink, attributes::unused, context);
    }
 
    template<typename OutputIterator, typename Context>
@@ -290,6 +312,18 @@ struct documentation_generator
       return generate_tag(sink, "value", text, context);
    }
 
+   template<typename OutputIterator, typename Context>
+   bool generate_tag_example(OutputIterator sink, std::string const& example, 
Context const& context) const
+   {
+      if (!as_generator(scope_tab(scope_size) << "/// ").generate(sink, 
attributes::unused, context)) return false;
+      if (!generate_opening_tag(sink, "example", context)) return false;
+      if (!generate_opening_tag(sink, "code", context)) return false;
+      if (!generate_escaped_content(sink, example, context)) return false;
+      if (!generate_closing_tag(sink, "code", context)) return false;
+      if (!generate_closing_tag(sink, "example", context)) return false;
+      return as_generator("\n").generate(sink, attributes::unused, context);
+   }
+
    // Actual exported generators
    template<typename OutputIterator, typename Attribute, typename Context>
    bool generate(OutputIterator sink, Attribute const& attr, Context const& 
context) const

-- 


Reply via email to