Menu

dot graph of statemachine in a single line with "Doxygen Preprocessor"

2017-06-29
2020-01-13
  • Alexander Eberle

    Hello

    I tried to generate the graph of a statemachine with "Doxygen Preprocessor".

    I use the following code:

    typedef enum
    {
      STATE1,
      STATE2
    } STATE;
    
    void StatemachineDemo(void)
    {
      STATE state{STATE1, STATE2};
    
      /** @statemachine */
      switch (state)
      {
        case STATE1:
          /** Label "State 1" */
    
            state = STATE2;
          break;
    
        case STATE2:
          /** Label "State 2" */
    
            state = STATE1;
          break;
      }
      /** @endstatemachine */
    }
    

    But unfortunately, the resulting graph doesn't work as single line:

    /* @dot digraph { STATE1 [label="State 1" URL="\ref STATE1"]; {rank=source; STATE1;}; STATE1 -> STATE2; STATE2 [label="State 2" URL="\ref STATE2"]; STATE2 -> STATE1; } @enddot /

    Doxygen delivers the following warnings:
    (line 11) warning: Illegal command enddot as part of a \dot
    (line 12) warning: dot section ended without end marker

    The same graph works splitted in two lines, directly after @dot:
    /* @dot
    digraph { STATE1 [label="State 1" URL="\ref STATE1"]; {rank=source; STATE1;}; STATE1 -> STATE2; STATE2 [label="State 2" URL="\ref STATE2"]; STATE2 -> STATE1; } @enddot
    /

    The graph is produced by Doxygen Preprocessor. This input filter catches the input from comments scattered through the code and automatically passes the processed data to doxygen. The graph results in a single line.

    I found out, that input filters have to keep the line numbers for doxygen. Though, the filter just replaces the statement @endstatemachine with the desired graph in a single line.

    I like this input filter, because I can place the documenation into the states. This enhances the maintainability of code and comments.

    Do you have any idea to get the single-line-graph running? Or is there another possibility to define a statemachine in several blocks?

    I use doxygen version 1.8.13.

    Thank you.

     
  • Alexander Eberle

    Hello

    Is there anyone using Doxygen Preprocessor?

     
  • Marco Caduff

    Marco Caduff - 2019-12-05

    Hello Alexander,

    did you ever get this working?

     
  • Alexander Eberle

    Hello Marco,

    no, this is still not working. I split up the state machine and its documentation. It looks like this:

    typedef enum
    {
      STATE1,
      STATE2
    } STATE;
    
    /*!---------------------------------------------------------------------
     \brief        Demonstration of Statemachine documentation
     \details      Workaround with documentation split up from source code.
    
     \dot
     digraph G {
       STATE1 -> STATE2;
       STATE2 -> STATE1;
     }
     \enddot
     */
    //----------------------------------------------------------------------
    void StatemachineDemo(void)
    {
      STATE state{STATE1, STATE2};
    
      switch (state)
      {
        case STATE1:
            state = STATE2;
          break;
    
        case STATE2:
            state = STATE1;
          break;
      }
    }
    
     
  • gas ase

    gas ase - 2021-09-05
    Post awaiting moderation.

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.