In Javadoc I can represent a hyperlink as #see http://google.com. How can I do this in Kotlin?
Well, actually, hyperlinks and #see tags are two separate matters in KDoc, meaning that #see is only limited to API references:
/**
* #see [Object.toString]
*/
class C
Hyperlinks per se use the regular Markdown syntax (but, unlike JavaDoc, can't be mixed with #see tags):
/**
* **See Also:** [Google](http://google.com)
*/
class C
Related
I am using IntelliJ IDEA for Kotlin and have a nice enum with documented items:
enum class TestEnum {
/** A comment for the item #1. */
ITEM1,
/** A comment for the item #2. */
ITEM2,
/** A comment for the item #3. */
ITEM3
}
It look nice and pretty. But when I use automatic code formatting it make it like this:
enum class TestEnum {
/** A comment for item #1. */
ITEM1,
/** A comment for item #2. */
ITEM2,
/** A comment for item #3. */
ITEM3
}
It an an adds empty line before every comment. If there are a lot of items and especially if it's a nested enum it's starting to look ugly and hard to read. The same this happens with documented properties or methods.
Is there any setting to prevent that?
This behavior was implemented recently in the Kotlin plugin 1.3.70. I created a request to disable it: https://youtrack.jetbrains.com/issue/KT-37420. Please follow this issue for updates.
The workaround is to use an older version of Kotlin plugin (1.3.61).
I'm looking for a way to set up code formatting to keep javadoc in enums in separate blocks. Right now wrapping of enum members works as intended, but for some reason javadoc comments start/end on the same line as the members
I'd keep getting this:
public enum FormatTest {
FOO, /**
* some description
*/BAR, BAZ;
}
but I want it to look something like this:
public enum FormatTest {
FOO,
/**
* docs either like this
*/
BAR,
/** or like this */
BAZ;
}
It works perfectly well for class members strangely enough...
try changing the Code Style settings.
In IntelliJ, go to: Settings -> Code Style -> Java -> Wrapping and Braces tab.
Scroll down untill you see Enum constants, and change the value to: Wrap always.
See screenshot
I'm attempting to have an Fileable trait that will give provide an Entity with methods to CRUD Files based on the File Entity mentioned below.
After reading the documentation on Doctrine and searching the internet, the best I could find is Inheritance Mapping but these all require the subclass to extend the superclass which is not ideal as the current Entities already extend other classes. I could have FileFoo entity and a FileBar entity but this gets too messy and requires an extra join (super -> sub -> entity).
Alternatively, I could have a File Entity which has many columns for Entities (so foo_id for the Foo object, bar_id for the bar object and so on) but this gets messy and would require a new column for every entity that I'd want to add the Fileable trait too.
So to the questions:
Am I thinking about how I want to hold data incorrectly?
Is there some features/functions in Doctrine/Symfony that I've missed?
Do you think I feature like this would be added if I were to fork Doctrine to add this feature, also where should I look?
<?php
/**
* File
*
* #ORM\Table()
* #ORM\Entity()
* #ORM\HasLifecycleCallbacks()
*/
class File
{
/**
* #var integer
*
* #ORM\Column(type="integer")
* #ORM\Id()
* #ORM\GeneratedValue()
*/
protected $id;
/**
* #var string
*
* #ORM\Column(type="string")
*/
protected $entityName;
/**
* #var string
*
* #ORM\Column(type="string")
*/
protected $entityId;
...
I accomplished a similar thing using Inheritance defined in traits, which alongside interfaces, basically gave me what a multiple extend would give.
Take a look at embeddables or you could use traits.
I'm using Doctrine ORM in a project that I am working on. Although the idea of providing an object interface to the db is nice, I have a question about the implementation of the entity classes.
Let's consider this example of a User entity:
<?php
/**
* #Entity #Table(name="users")
**/
class User
{
/**
* #Id #GeneratedValue #Column(type="integer")
* #var int
**/
protected $id;
/**
* #Column(type="string")
* #var string
**/
protected $name;
/**
* #OneToMany(targetEntity="Bug", mappedBy="reporter")
* #var Bug[]
**/
protected $reportedBugs = null;
/**
* #OneToMany(targetEntity="Bug", mappedBy="engineer")
* #var Bug[]
**/
protected $assignedBugs = null;
// .. (other code)
}
Now, its all fine and dandy, but I was wondering what would happen if I make a spelling mistake in one of the comments e.g. I write:
#Table(name="users)
instead of
#Table(name="users")
the IDE will not complain since its a comment, and I'll only get an error when I run the "generate entities" command (that does the magic in the background of generating code, creating tables, columns and relationships).
So my question is: Aren't entity definitions for ORM error prone? since there really is no check on the syntax if its valid, and errors are generated only at 'generate' time. Is there a way to automate / check for mistakes earlier on while development?
Thanks!
IMO, The issue that you highlighted can be compared to using wrong variables in PHP ($var1 instead of $var2). For that matter, in all dynamic languages.
But you can avoid the problem highlighted by you, if you write unit tests.
I have an enum in my .h file like so:
/** \memberof MyClass
Values for keypress bitmasks for #method and MyClassDelegate#otherMethod */
enum MY_KEYS {
MY_KEY_1_DOWN, /**< KEY 1 press */
MY_KEY_1_UP, /**< KEY 1 release */
MY_KEY_2_DOWN, /**< KEY 2 press */
MY_KEY_2_UP, /**< KEY 2 release */
};
Doxygen generates an entry for this enum under "Public Types" as well as "Member Enumeration Documentation" where the detailed descriptions show up. However, it generates no documentation for the members of the enumeration. I want to list the members of my enumerations and comment them, so that my users can know which values to use where they formal type of an argument is this enumeration.
Don't know if it's relevant--this is in Objective-C, hence \memberof MyClass to show up on this class's page.
Not sure why doxygen doesn't see enum values as inherited by the \memberof command. It doesn't work if you manually set the individual values as members of the enum or class either.
Anyway, the workaround is that if you want the enum to actually appear inside the class, you need to define it within the class interface:
#interface MyClass : NSobject
/**
Values for keypress bitmasks for #method and MyClassDelegate#otherMethod
*/
enum MY_KEYS {
MY_KEY_1_DOWN, /**< KEY 1 press */
MY_KEY_1_UP, /**< KEY 1 release */
MY_KEY_2_DOWN, /**< KEY 2 press */
MY_KEY_2_UP, /**< KEY 2 release */
};
#end
This actually makes more sense IMO, as there's no guarantee that header files contain related types - it's just expected of good design.
I stumbled over the same problem (although for a pure C documentation) - unfortunately this seems to be an issue with Doxygen, see the corresponding Bugzilla entry
individual values in enum not documented if the enum is a member of a
C class
https://bugzilla.gnome.org/show_bug.cgi?id=762320
or the older related bug:
When #relatesalso is used, Doxygen does not output members of enum.
https://bugzilla.gnome.org/show_bug.cgi?id=609299
Update:
A quick fix which solves this problem (tested in Doxygen 1.8.11):
Edit src/doxygen.cpp and remove (or comment) line 7375 in function addEnumValuesToEnums:
if (!e->name().isEmpty() && (fmn=(*emnsd)[e->name()]))
// get list of members with the same name as the field
{
MemberNameIterator fmni(*fmn);
MemberDef *fmd;
for (fmni.toFirst(); (fmd=fmni.current()) ; ++fmni)
{
/* REMOVED LINE 7375: if (fmd->isEnumValue() && fmd->getOuterScope()==md->getOuterScope()) // in same scope */
{
//printf("found enum value with same name %s in scope %s\n",
// fmd->name().data(),fmd->getOuterScope()->name().data());
if (nd && !nd->name().isEmpty() && nd->name().at(0)!='#')
{
The "outer scope" of the C enum was still set to global, i.e. the block which adds enum member values had not been reached.
Please note that I made just a short check and did not thoroughly test the fix - it might have side-effects....