summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-04-11 10:37:33 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-04-11 10:37:45 +0200
commit748070125ff43c001feb8e191cf2be8d0f59d01d (patch)
tree6e69ff0dc647a6ccf2f777287b098096dbb8dcf8 /src/bin
parentc3907032b6de5e24867e15e09af8f9146810a8cc (diff)
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
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh40
1 files 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
244 244
245 /// Tag generator helpers 245 /// Tag generator helpers
246 template<typename OutputIterator, typename Context> 246 template<typename OutputIterator, typename Context>
247 bool generate_tag(OutputIterator sink, std::string const& tag, std::string const &text, Context const& context, std::string tag_params = "") const 247 bool generate_opening_tag(OutputIterator sink, std::string const& tag, Context const& context, std::string tag_params = "") const
248 {
249 return as_generator("<" << tag << tag_params << ">").generate(sink, attributes::unused, context);
250 }
251
252 template<typename OutputIterator, typename Context>
253 bool generate_closing_tag(OutputIterator sink, std::string const& tag, Context const& context) const
254 {
255 return as_generator("</" << tag << ">").generate(sink, attributes::unused, context);
256 }
257
258 template<typename OutputIterator, typename Context>
259 bool generate_escaped_content(OutputIterator sink, std::string const &text, Context const& context) const
248 { 260 {
249 std::string new_text; 261 std::string new_text;
250 if (!as_generator(html_escaped_string).generate(std::back_inserter(new_text), text, context)) 262 if (!as_generator(html_escaped_string).generate(std::back_inserter(new_text), text, context))
@@ -256,14 +268,24 @@ struct documentation_generator
256 268
257 std::istringstream ss(new_text); 269 std::istringstream ss(new_text);
258 std::string para; 270 std::string para;
259 std::string final_text = "<" + tag + tag_params + ">"; 271 std::string final_text;
260 bool first = true; 272 bool first = true;
261 while (std::getline(ss, para)) { 273 while (std::getline(ss, para)) {
262 if (first) final_text += para; 274 if (first) final_text += para;
263 else final_text += "\n" + tabs + para; 275 else final_text += "\n" + tabs + para;
264 first = false; 276 first = false;
265 } 277 }
266 return as_generator(scope_tab(scope_size) << "/// " << final_text << "</" << tag << ">\n").generate(sink, attributes::unused, context); 278 return as_generator(final_text).generate(sink, attributes::unused, context);
279 }
280
281 template<typename OutputIterator, typename Context>
282 bool generate_tag(OutputIterator sink, std::string const& tag, std::string const &text, Context const& context, std::string tag_params = "") const
283 {
284 if (!as_generator(scope_tab(scope_size) << "/// ").generate(sink, attributes::unused, context)) return false;
285 if (!generate_opening_tag(sink, tag, context, tag_params)) return false;
286 if (!generate_escaped_content(sink, text, context)) return false;
287 if (!generate_closing_tag(sink, tag, context)) return false;
288 return as_generator("\n").generate(sink, attributes::unused, context);
267 } 289 }
268 290
269 template<typename OutputIterator, typename Context> 291 template<typename OutputIterator, typename Context>
@@ -290,6 +312,18 @@ struct documentation_generator
290 return generate_tag(sink, "value", text, context); 312 return generate_tag(sink, "value", text, context);
291 } 313 }
292 314
315 template<typename OutputIterator, typename Context>
316 bool generate_tag_example(OutputIterator sink, std::string const& example, Context const& context) const
317 {
318 if (!as_generator(scope_tab(scope_size) << "/// ").generate(sink, attributes::unused, context)) return false;
319 if (!generate_opening_tag(sink, "example", context)) return false;
320 if (!generate_opening_tag(sink, "code", context)) return false;
321 if (!generate_escaped_content(sink, example, context)) return false;
322 if (!generate_closing_tag(sink, "code", context)) return false;
323 if (!generate_closing_tag(sink, "example", context)) return false;
324 return as_generator("\n").generate(sink, attributes::unused, context);
325 }
326
293 // Actual exported generators 327 // Actual exported generators
294 template<typename OutputIterator, typename Attribute, typename Context> 328 template<typename OutputIterator, typename Attribute, typename Context>
295 bool generate(OutputIterator sink, Attribute const& attr, Context const& context) const 329 bool generate(OutputIterator sink, Attribute const& attr, Context const& context) const