q66 pushed a commit to branch master.

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

commit aa65c7ef5b5f0a05d33c842630d9cf6143977237
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Thu Aug 6 16:53:41 2015 +0100

    eolian: @since no longer needs to be its own paragraph in docs
    
    However, it still terminates the doc.
---
 src/lib/eolian/eo_lexer.c     | 102 +++++++++++++++++++++++-------------------
 src/tests/eolian/data/docs.eo |   4 +-
 2 files changed, 57 insertions(+), 49 deletions(-)

diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 35bb3d0..6d8559c 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -258,12 +258,12 @@ enum Doc_Tokens {
 };
 
 static int
-doc_lex(Eo_Lexer *ls, Eina_Bool *term)
+doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since)
 {
    int tokret = -1;
-   Eina_Bool contdoc = EINA_FALSE;
    eina_strbuf_reset(ls->buff);
-   for (;; contdoc = EINA_TRUE) switch (ls->current)
+   *since = EINA_FALSE;
+   for (;;) switch (ls->current)
      {
       /* error case */
       case '\0':
@@ -315,66 +315,67 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term)
           }
         eina_strbuf_append_char(ls->buff, ']');
         continue;
-      /* @since case - only when starting a new paragraph */
+      /* references and @since */
       case '@':
-        eina_strbuf_append_char(ls->buff, '@');
-        next_char(ls);
-        if (contdoc)
+        if ((size_t)(ls->stream_end - ls->stream) >= (sizeof("since")) &&
+            !memcmp(ls->stream, "since ", sizeof("since")))
           {
-             /* in-class references */
-             if (ls->tmp.kls && ls->current == '.')
-               {
-                  next_char(ls);
-                  if (isalpha(ls->current) || ls->current == '_')
-                    eina_strbuf_append(ls->buff, ls->tmp.kls->full_name);
-                  eina_strbuf_append_char(ls->buff, '.');
-                  continue;
-               }
-             continue;
-          }
-        while (ls->current && isalpha(ls->current))
-          {
-             eina_strbuf_append_char(ls->buff, ls->current);
              next_char(ls);
+             *since = EINA_TRUE;
+             for (size_t i = 0; i < sizeof("since"); ++i)
+               next_char(ls);
+             skip_ws(ls);
+             tokret = DOC_TEXT;
+             goto exit_with_token;
           }
-        if (!strcmp(eina_strbuf_string_get(ls->buff), "@since"))
+        eina_strbuf_append_char(ls->buff, '@');
+        next_char(ls);
+        /* in-class references */
+        if (ls->tmp.kls && ls->current == '.')
           {
-             /* since-token */
-             eina_strbuf_reset(ls->buff);
-             skip_ws(ls);
-             while (ls->current && (ls->current == '.' ||
-                                    ls->current == '_' ||
-                                    isalnum(ls->current)))
-               {
-                  eina_strbuf_append_char(ls->buff, ls->current);
-                  next_char(ls);
-               }
-             if (!eina_strbuf_length_get(ls->buff))
-               return DOC_UNFINISHED;
-             tokret = DOC_SINCE;
-             goto force_terminate;
+             next_char(ls);
+             if (isalpha(ls->current) || ls->current == '_')
+               eina_strbuf_append(ls->buff, ls->tmp.kls->full_name);
+             eina_strbuf_append_char(ls->buff, '.');
           }
+        continue;
       /* default case - append character */
       default:
         eina_strbuf_append_char(ls->buff, ls->current);
         next_char(ls);
         continue;
      }
+terminated:
+   next_char(ls);
+   *term = EINA_TRUE;
+exit_with_token:
+   eina_strbuf_trim(ls->buff);
+   return tokret;
+}
 
-force_terminate:
+static int
+read_since(Eo_Lexer *ls)
+{
+   eina_strbuf_reset(ls->buff);
+   while (ls->current && (ls->current == '.' ||
+                          ls->current == '_' ||
+                          isalnum(ls->current)))
+     {
+        eina_strbuf_append_char(ls->buff, ls->current);
+        next_char(ls);
+     }
+   if (!eina_strbuf_length_get(ls->buff))
+     return DOC_UNFINISHED;
    skip_ws(ls);
    while (is_newline(ls->current))
      next_line_ws(ls);
-   if (ls->current == ']')
-     next_char(ls);
    if (ls->current != ']')
      return DOC_MANGLED;
-terminated:
    next_char(ls);
-   *term = EINA_TRUE;
-exit_with_token:
-   eina_strbuf_trim(ls->buff);
-   return tokret;
+   if (ls->current != ']')
+     return DOC_MANGLED;
+   next_char(ls);
+   return DOC_SINCE;
 }
 
 void doc_error(Eo_Lexer *ls, const char *msg, Eolian_Documentation *doc, 
Eina_Strbuf *buf)
@@ -396,10 +397,17 @@ read_doc(Eo_Lexer *ls, Eo_Token *tok, int line, int 
column)
 
    Eina_Strbuf *rbuf = eina_strbuf_new();
 
-   Eina_Bool term = EINA_FALSE;
+   Eina_Bool term = EINA_FALSE, since = EINA_FALSE;
    while (!term)
      {
-        int read = doc_lex(ls, &term);
+        int read;
+        if (since)
+          {
+             read = read_since(ls);
+             term = EINA_TRUE;
+          }
+        else
+          read = doc_lex(ls, &term, &since);
         switch (read)
           {
            case DOC_MANGLED:
@@ -409,6 +417,8 @@ read_doc(Eo_Lexer *ls, Eo_Token *tok, int line, int column)
              doc_error(ls, "unfinished documentation", doc, rbuf);
              return;
            case DOC_TEXT:
+             if (!eina_strbuf_length_get(ls->buff))
+               continue;
              if (!doc->summary)
                doc->summary = 
eina_stringshare_add(eina_strbuf_string_get(ls->buff));
              else
diff --git a/src/tests/eolian/data/docs.eo b/src/tests/eolian/data/docs.eo
index 9da0745..90b016c 100644
--- a/src/tests/eolian/data/docs.eo
+++ b/src/tests/eolian/data/docs.eo
@@ -23,9 +23,7 @@ enum Bar {
 type Alias: Bar; [[Docs for typedef.
 
                    More docs for typedef.
-                   See @Bar.
-
-                   @since 2.0
+                   See @Bar. @since 2.0
                  ]]
 
 var pants: int = 150; [[Docs for var.]]

-- 


Reply via email to