Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. how to tell QtCreator to ignore one .cpp file.

how to tell QtCreator to ignore one .cpp file.

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
8 Posts 2 Posters 947 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by ODБOï
    #1

    Hi,
    I have a .cpp file containing only code snippets for my project documentation. I use Doxygen.

    // examples.cpp
    //! [ex1]
    if (index < 0 || index >= m_backends.size())
        return;
    //! [ex1]
    
    //! [ex2]
    QObject::connect(m_client.data(), &QOpcUaClient::stateChanged, this, &MachineBackend::clientStateHandler);
    //! [ex2]
    
    

    to use it

    // one "real" cpp file
    /// \snippet examples.cpp ex1
    if (index < 0 || index >= m_backends.size())
        return; // Invalid index
    

    Then i get the snippet as expected in the doc.

    Unfortunately i cannot compile my project with that examples.cpp file.

    Is this the right way to handle Doxygen snippets (with a separate file) ?
    i feel like it is not the right way because if i change my code i will have to manually adapt (copy/past) the new code in the snipetts file

    How to ignore that examples.cpp file so i can build my project again ?

    Thank you

    note : I did this separate file because if i add the snippet directly in the real code

    // the"real" cpp file
    
    //! [ex1]
    /// \snippet ThisFile.cpp ex1
    if (index < 0 || index >= m_backends.size())
        return; // Invalid index
    //! [ex1]
    

    this almost works, in the doc (generated html) i can see the snippet but i can also see the //![ex1]

    the output is exactly like this

    //! [ex1]
    /// \snippet ThisFile.cpp ex1
    if (index < 0 || index >= m_backends.size())
        return; // Invalid index
    //! [ex1]
    
    sierdzioS 1 Reply Last reply
    0
    • ODБOïO ODБOï

      Hi,
      I have a .cpp file containing only code snippets for my project documentation. I use Doxygen.

      // examples.cpp
      //! [ex1]
      if (index < 0 || index >= m_backends.size())
          return;
      //! [ex1]
      
      //! [ex2]
      QObject::connect(m_client.data(), &QOpcUaClient::stateChanged, this, &MachineBackend::clientStateHandler);
      //! [ex2]
      
      

      to use it

      // one "real" cpp file
      /// \snippet examples.cpp ex1
      if (index < 0 || index >= m_backends.size())
          return; // Invalid index
      

      Then i get the snippet as expected in the doc.

      Unfortunately i cannot compile my project with that examples.cpp file.

      Is this the right way to handle Doxygen snippets (with a separate file) ?
      i feel like it is not the right way because if i change my code i will have to manually adapt (copy/past) the new code in the snipetts file

      How to ignore that examples.cpp file so i can build my project again ?

      Thank you

      note : I did this separate file because if i add the snippet directly in the real code

      // the"real" cpp file
      
      //! [ex1]
      /// \snippet ThisFile.cpp ex1
      if (index < 0 || index >= m_backends.size())
          return; // Invalid index
      //! [ex1]
      

      this almost works, in the doc (generated html) i can see the snippet but i can also see the //![ex1]

      the output is exactly like this

      //! [ex1]
      /// \snippet ThisFile.cpp ex1
      if (index < 0 || index >= m_backends.size())
          return; // Invalid index
      //! [ex1]
      
      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @LeLev said in how to say QtCreator to ignore one .cpp file.:

      Unfortunately i cannot compile my project with thatexamples.cpp file.

      Is this the right way to handle Doxygen snippets (with a separate file) ?
      How to ignore that examples.cpp file so i can build my project again ?

      Do not put it in SOURCES in your qmake file. Only add it as input file in doxygen configuration file.

      (Z(:^

      ODБOïO 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @LeLev said in how to say QtCreator to ignore one .cpp file.:

        Unfortunately i cannot compile my project with thatexamples.cpp file.

        Is this the right way to handle Doxygen snippets (with a separate file) ?
        How to ignore that examples.cpp file so i can build my project again ?

        Do not put it in SOURCES in your qmake file. Only add it as input file in doxygen configuration file.

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @sierdzio thank you ! that worked.

        The annoying part is that i will have to change the examples manually if i change my code one day.

        Any solution to make this automated ?

        sierdzioS 1 Reply Last reply
        0
        • ODБOïO ODБOï

          @sierdzio thank you ! that worked.

          The annoying part is that i will have to change the examples manually if i change my code one day.

          Any solution to make this automated ?

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @LeLev said in how to tell QtCreator to ignore one .cpp file.:

          @sierdzio thank you ! that worked.

          The annoying part is that i will have to change the examples manually if i change my code one day.

          Any solution to make this automated ?

          Well, define the snippet in real code. How is described here: http://doxygen.nl/manual/commands.html#cmdsnippet

          In your code I think you have an error that your put \snippet inside of `[ex1] markers. Remove that and it should work.

          (Z(:^

          ODБOïO 1 Reply Last reply
          3
          • sierdzioS sierdzio

            @LeLev said in how to tell QtCreator to ignore one .cpp file.:

            @sierdzio thank you ! that worked.

            The annoying part is that i will have to change the examples manually if i change my code one day.

            Any solution to make this automated ?

            Well, define the snippet in real code. How is described here: http://doxygen.nl/manual/commands.html#cmdsnippet

            In your code I think you have an error that your put \snippet inside of `[ex1] markers. Remove that and it should work.

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            @sierdzio thx
            i have tryed like this also

                /// \snippet thisClassName.cpp ex1
                //! [ex1]
                QString program = "Gview.exe";
                QString filePath = file.replace("/","\\");
                QProcess *myProcess = new QProcess(this);
                myProcess->start(program, QStringList() << filePath ); 
                //! [ex1]
            

            but the output is still polluted with the special snippet markers

            output in the generated html page looks like :

                QString program = "GCodeView.exe";
                QString filePath = file.replace("/","\\");
                QProcess *myProcess = new QProcess(this);
                myProcess->start(program, QStringList() << filePath ); 
            [ex1]
            
            [ex1]
            
            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              No idea, it looks like a doxygen bug perhaps? There is also the \dontinclude command which should work without the [ex1] markers.

              (Z(:^

              ODБOïO 1 Reply Last reply
              1
              • sierdzioS sierdzio

                No idea, it looks like a doxygen bug perhaps? There is also the \dontinclude command which should work without the [ex1] markers.

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                @sierdzio said in how to tell QtCreator to ignore one .cpp file.:

                \dontinclude

                i'm fiddling with that one right now

                ODБOïO 1 Reply Last reply
                0
                • ODБOïO ODБOï

                  @sierdzio said in how to tell QtCreator to ignore one .cpp file.:

                  \dontinclude

                  i'm fiddling with that one right now

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by ODБOï
                  #8

                  @sierdzio said in how to tell QtCreator to ignore one .cpp file.:

                  it looks like a doxygen bug perhaps

                  yes it looks like a bug..

                  the cleanest way i found is

                      //! [ex1] \dontinclude
                      QString program = "GView.exe";
                      QString filePath = file.replace("/","\\");
                      QProcess *myProcess = new QProcess(this);
                      myProcess->start(program, QStringList() << filePath ); 
                      //! [ex1] How to run <b>Gview.exe</b> ?
                      //!\snippet machinebackend.cpp ex1
                  
                  

                  the output is still polluted but it's ok for me

                  output :

                  [ex1] [ex1] How to run Gview.exe ?
                  
                      QString program = "GCodeView.exe";
                      QString filePath = file.replace("/","\\");
                      QProcess *myProcess = new QProcess(this);
                      myProcess->start(program, QStringList() << filePath );
                  

                  Thank you again @sierdzio

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved