2011-11-08 3 views
2

PHP에서 디자인 패턴을 사용하는 메서드에 대한 문서를 작성하려고합니다. 일반적으로 메소드에는 관찰자, 인터셉트 필터 및 통지자가 포함됩니다. 이것을 어떻게 php docs에 맞는 형식으로 작성할 수 있습니까? 설명서를 작성하는 함수의 예는 다음과 같습니다. 그리고 내 서식이 꺼져있어 문서 작성에 더 익숙해 질 수 있는지 알려주십시오.PHP에서 디자인 패턴을 문서화하는 방법

/** 
    * Creates a checkbox input element with options passed too it. 
    * 
    * @see PVHTML::getStandardAttributes() 
    * @see PVHTML::getEventAttributes() 
    * @see PVHTML::getStandardAttributes() 
    * @see self::getFormAttributes() 
    * 
    * @param string $name The name of the input being generated. Will be the input field's name 
    * @param array $options Options than can be used to further distinguish the element. The options are 
    *    the same values that will be passed through PVHTML::getStandardAttributes, PVHTML::getEventAttributes 
    *    and get the self::getFormAttributes functions 
    * @param array $css_options Options than can define how the CSS is styled around the form the div around the element. 
    *    Options will be passed to PVHTML::getStandardAttributes() and PVHTML::getEventAttributes(). Have the option 
    *    'disable_css' will disable the div surrouding the element. 
    * 
    * @return string $element The string that creates the element 
    * @access public 
    */ 
    public static function checkbox($name, $options=array(), $css_options=array()) { 

     if(self::_hasAdapter(get_class(), __FUNCTION__)) 
      return self::_callAdapter(get_class(), __FUNCTION__, $name, $options, $css_options); 

     $filtered = self::_applyFilter(get_class(), __FUNCTION__ , array('name'=>$name, 'options'=>$options, 'css_options'=>$css_options), array('event'=>'args')); 
     $name = $filtered['name']; 
     $options = $filtered['options']; 
     $css_options = $filtered['css_options']; 

     $css_defaults=array('class'=>'form-checkbox'); 
     $css_options += $css_defaults; 

     $input = self::input($name, 'checkbox', $options, $css_options);; 
     self::_notify(get_class().'::'.__FUNCTION__, $input, $name, $options, $css_options); 
     $input = self::_applyFilter(get_class(), __FUNCTION__ , $input , array('event'=>'return'));  

     return $input; 
    } 

답변

2

의견이 너무 많아서 의견을 너무 적게 작성하는 경향이 있습니다. 예 : 함수가 checkbox이고 매개 변수가 $name 인 경우 확인란의 이름임을 문서 할 필요가 없습니다. 그것은 분명합니다.

그런 식으로 @see를 사용할 필요는 없습니다. 그것은 중복 된 코드입니다. 변경되면 주석도 변경해야합니다. 이 작업은 올바르게 수행되지 않으므로 앞으로 오해의 소지가있는 문서가됩니다. 그것은 피해야합니다.

어쨌든 코드를 살펴보면 어떤 기능이 사용되는지 알 수 있습니다.

의견을 쓰는 경우 기본 내용 : 누가 무엇을하는지 (이유가 아닌) 작은 문장을 사용하십시오. 무언가가 창조되면, 누구에 의하여 쓰십시오. "요소를 만드는 문자열"이 아닙니다. 어떤 요소 요? 문자열이 어떻게 만들 수 있습니까? 그것은 단지 데이터 일뿐입니다. 단지 데이터 일 뿐이므로 더 좋을 수도 있습니다.

* @return string HTML 

이렇게 함수가 반환하는 것은 분명합니다.

관련 문제