1

I am trying to use code blocks with Doxygen; however, this method I've used does not seem intuitive and I am wondering if there's a better method, that will include inline code.

public class DropZone : MonoBehaviour
{
    private void OnCollisionEnter(Collision collision)//! resets an object that collides with the dropzone.
    {
        ///\code
        //!collision.gameObject.GetComponent<StorePos>().ResetPos();
        ///\endcode
        collision.gameObject.GetComponent<StorePos>().ResetPos();//! if anything drops bellow the counter it will reset the pos to initial

    }
}

I'll give an example of the syntax that I would like:

public class DropZone : MonoBehaviour
{
    private void OnCollisionEnter(Collision collision)//! resets an object that collides with the dropzone.
    {
        ///\code
        collision.gameObject.GetComponent<StorePos>().ResetPos();//! if anything drops bellow the counter it will reset the pos to initial
        ///\endcode

    }
}
  • There are e number of possibilities like the setting `INLINE_SOURCES` or the `\snippet` command or a set of commands like `\dontinclude`, \line` etc. – albert Sep 17 '19 at 13:44
  • @albert I see so I would have to use example files and the syntax would be \snippet ... – Sebastian Djurovic Sep 17 '19 at 14:28
  • You don't need example files (only the EXAMPLE_PATH has to be set, historical reason), but the snippet directives and the snippet command can be from the same file. – albert Sep 17 '19 at 14:53
  • in general: Comments belong **on top** of the according code line .. not behind it – derHugo Sep 17 '19 at 14:54
  • @derHugo fortunately you wrote "in general", when you have a list of variables this would disrupt the readability of the code and it would be better to place it behind the variable. – albert Sep 17 '19 at 14:58
  • @albert what do you mean a list of variables? Anyway the according comment always belongs on top of a code line .. this is common practise. The reason: It is at any moment possible that you will want to convert it to a block comment due to needing multiple lines ... having them all behind the according code completely breaks your system and is even worse in readability ... e.g. you will see no inline comment in [Documenting your code with XML comments](https://learn.microsoft.com/dotnet/csharp/codedoc) – derHugo Sep 17 '19 at 15:14
  • @derHugo, I'm talking about variables in e.g. classes. For routines / methods I agree the that the documentation should be before the routine. – albert Sep 17 '19 at 15:28
  • @albert as said .. for fields and properties as well ;) – derHugo Sep 17 '19 at 15:38
  • @derHugo for fields on top? when having a lot of fields it is much more readable in the code to have it after the field (and let the documentation process handle where it places it in the documentation). – albert Sep 17 '19 at 15:40
  • @albert as said already ... it simply is common practise and I want see how you make a long comment for a certain field all in one line ... ^^ The documentation doesn't decide where it places stuff but it is simply read and generated top to bottom. I would always instantly refactor code of someone who has put comments behind code lines .. you just don't do that ... in general .. and by that I ment no matter what ;) – derHugo Sep 17 '19 at 15:45
  • @derHugo common practice is nice but where the documentation has to be placed is up to the project and something that one does like isn't in the liking of others. A good documentation tool will support both versions. and long comments can be nicely, aligned, placed behind a field (it looks like a bit of a table in that way). See for documentation after a member e.g. http://www.doxygen.nl/manual/docblocks.html#memberdoc (especially the parts with enums). The mentioned documentation mixes different styles, this is not nice in a real project but done there to show the possibilities. – albert Sep 17 '19 at 15:53
  • Thank you for all your help. – Sebastian Djurovic Sep 17 '19 at 17:54

0 Answers0