-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fill in class and property documentation based on Database Comments #226
base: master
Are you sure you want to change the base?
Conversation
generators/model/default/model.php
Outdated
* | ||
<?php foreach ($tableSchema->columns as $column): ?> | ||
* @property <?= "{$column->phpType} \${$column->name}\n" ?> | ||
* @property <?= "{$column->phpType} \${$column->name}" . ($column->comment ? " " . strtr($column->comment, ["\n" => "\n * "]) : '') . "\n" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't be used like that since there's already an option in Gii Model generator "Generate Labels from DB Comments".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, labels are not generated from table comments, just column comments. these are not conflicting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is about column comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but now I'm confused, how are column comments handled if not in this line!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we use db comments for form labels and also property documentation at the same time? It does make sense, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, now I see. This line should respect the $generateLabelsFromComments
and only add the comments here if they are not used as labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, you are right, @michaelarnauts we could still add them here, better have the label, than no documentation or description at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about it... it makes sense.
generators/model/default/model.php
Outdated
* | ||
<?php foreach ($tableSchema->columns as $column): ?> | ||
* @property <?= "{$column->phpType} \${$column->name}\n" ?> | ||
* @property <?= "{$column->phpType} \${$column->name}" . ($column->comment ? " " . strtr($column->comment, ["\n" => "\n * "]) : '') . "\n" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but now I'm confused, how are column comments handled if not in this line!?
generators/model/default/model.php
Outdated
* | ||
<?php foreach ($tableSchema->columns as $column): ?> | ||
* @property <?= "{$column->phpType} \${$column->name}\n" ?> | ||
* @property <?= "{$column->phpType} \${$column->name}" . ($column->comment ? " " . strtr($column->comment, ["\n" => "\n * "]) : '') . "\n" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, now I see. This line should respect the $generateLabelsFromComments
and only add the comments here if they are not used as labels.
What has kept this pull request from being merged? (It seems that is has gotten conflicts in the meantime). Can this be accepted when the conflicts are resolved? |
7f7c267
to
090218b
Compare
To recap, this doesn't change any code or changes the model in any way. It just makes sure that db comments are added to the phpdoc, so any IDE can use this to give additional information about the property or table object. |
generators/model/Generator.php
Outdated
'type' => $type, | ||
'name' => $column->name, | ||
'description' => $column->comment, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems your last commit changed the diff to something wrong. This change looks unrelated to the changes below...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, at least comment
and description
do not match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also need the comments, so it cant be just key => value. The name is just for completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but you are creating the key description
here, which you are using comment
in the code below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ow, right. Sorry, will fix that.
090218b
to
5ff79ae
Compare
I have merged the property comment part, thank you! Keeping this open for the class comment when it is supported in the framework. |
Depends on yiisoft/yii2#13162 for table comments.
I'm not sure if there has to be an option to enable this. This is just for comments, and doesn't have an impact on functionality or code.