Skip to content
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

Use table comments for documentor's variable description #131

Closed
wants to merge 1 commit into from

Conversation

stmswitcher
Copy link

Hello!

I am using PHPdoc comments a lot in my work and in Yii projects I have to copy-paste the db fileds' descriptions into my models, most of which is generated by gii. So, I've made some changes in gii's model generator to use the db comments in model's doc-block.

It's not such a big thing, but may be usefull for those who is using PHPdoc in their IDE.

The changes include generator propery, corresponding checkbox and default model template.

@SilverFire
Copy link
Member

Looks good to me

@stmswitcher
Copy link
Author

Btw, I don't use gii for enything but the models, so there's not any changes to other templates.

@Faryshta
Copy link
Contributor

what happens if my column comment has line breaks?

@cebe
Copy link
Member

cebe commented Apr 10, 2016

@Faryshta good point, line breaks should be replaced by "\n * ".

@cebe cebe added this to the 2.0.6 milestone Apr 10, 2016
@@ -24,7 +24,7 @@
* This is the model class for table "<?= $generator->generateTableName($tableName) ?>".
*
<?php foreach ($tableSchema->columns as $column): ?>
* @property <?= "{$column->phpType} \${$column->name}\n" ?>
* @property <?= "{$column->phpType} \${$column->name}" . ($generator->generateDocsFromComments ? " {$column->comment}" : '') . "\n" ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strtr($column->comment, ["\n" => "\n * "])

@michaelarnauts
Copy link

Is this feature considered to be included? Since this PR isn't up to date anymore, I'm willing to create a new one given that it can be merged.

Also, what about comments on the table itself? This information isn't currently available in the models, but it also could be read out (with a SHOW CREATE TABLE xxx in mysql for example). This would probably require a change in the db-classes.

@cebe
Copy link
Member

cebe commented Dec 7, 2016

Is this feature considered to be included?

yes, go ahead :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants