Best way to document Array options in PHPDoc?

前端 未结 9 590
天命终不由人
天命终不由人 2020-12-04 09:57

I\'m struggling to write readable and easy to understand documentation that describes the multi-tree structure for Array options that are passed to a function.

Here

9条回答
  •  春和景丽
    2020-12-04 10:11

    AS this is purely display rather than a directive, and should retain space formatting within the docs, I'd be inclined to go for readability with indentation rather than a wall of characters:

     * array['fields'] array Defines the feilds to be shown by scaffolding.
     *           [fieldName] array Defines the options for a field, or just enables
     *                             the field if array is not applied.
     *                 ['name'] string Overrides the field name (default is the
     *                                  array key)
     *                 ['model'] string (optional) Overrides the model if the field is
     *                                  a belongsTo assoicated value.
     *                 ['width'] string Defines the width of the field for paginate
     *                                  views.
     *                                  Examples are "100px" or "auto"
     *                 ['align'] string Alignment types for paginate views (left, 
     *                                 right, center)
     *                 ['format'] string Formatting options for paginate fields.
     *                                   Options include 'currency', 'nice',
     *                                  'niceShort', 'timeAgoInWords' or a valid 
     *                                  Date() format)
     *                 ['title'] string Changes the field name shown in views.
     *                 ['desc'] string The description shown in edit/create views.
     *                 ['readonly'] boolean True prevents users from changing the
     *                                 value in edit/create forms.
     *                 ['type'] string Defines the input type used by the Form helper
     *                                  (example 'password')
     *                 ['options'] array Defines a list of string options for drop-
     *                                  down lists.
     *                 ['editor'] boolean If set to True will show a WYSIWYG editor
     *                                  for this field.
     *                 ['default'] string The default value for create forms.
    

    Though using an actual PHP array definition with indentation is even cleaner

提交回复
热议问题