문제

I would like to build some smaller scale but hightly customized documentation sites for a few projects. PhpDocumentor is pretty great but it is very heavy. I thought about trying to tweak the templates for that but after spending only a couple of minutes looking into it I decided that it would be too much work.

Ideally I'd like to see something to which I could pass a bunch of files and have it return all of the files, classes and properties and methods, along with their meta data, so that I could build out some simple templates based on the data.

Are there any DocBlock parser-only projects that will help me in this task, or am I stuck reinventing that wheel?

도움이 되었습니까?

해결책

You can do this easily yourself with the Reflection API:

/**
 * This is an Example class
 */
class Example
{
    /**
     * This is an example function
     */
    public function fn() 
    {
        // void
    }
}

$reflector = new ReflectionClass('Example');

// to get the Class DocBlock
echo $reflector->getDocComment()

// to get the Method DocBlock
$reflector->getMethod('fn')->getDocComment();

See this tutorial: http://www.phpriot.com/articles/reflection-api

There is also a PEAR package that can parse DocBlocks.

다른 팁

In case someone needs a regular expression (xdazz suggested to try this and student310 commented it works for her/his needs)

if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $str, $matches)){
  $result = array_combine($matches[1], $matches[2]);
}

Example (Demo):

<?php
$str ='
/**    
 * @param   integer  $int  An integer
 * @return  boolean
 */
';
if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $str, $matches)){
  $result = array_combine($matches[1], $matches[2]);
}

var_dump($result);

Just to update the answers. You may also want to check out the phpDocumentor2 project. I think that it's PHP DocBlock parser can be easily extracted as standalone solution.

As furgas pointed out, I've been using phpDocumentor for years as a standalone project and it works fine.

<?php
$class = new ReflectionClass('MyClass');
$phpdoc = new \phpDocumentor\Reflection\DocBlock($class);

var_dump($phpdoc->getShortDescription());
var_dump($phpdoc->getLongDescription()->getContents());
var_dump($phpdoc->getTags());
var_dump($phpdoc->hasTag('author'));
var_dump($phpdoc->hasTag('copyright'));
  1. 페이지로드 SharePoint

    SharePoint 페이지의 경우 본문에 함수를 직접 추가 할 수 없습니다. onload 이벤트 ( 추가 정보 )

    그래서,이 선

    onload = getMap;
    
    .

    이이 하나로 교체해야합니다 :

    _spBodyOnLoadFunctionNames.push("getMap");
    

  2. 정의되지 않은 객체 참조 (오타 오류)

    라인

    listItems = targetList.getItems(query);
    
    .

    항상 정의되지 않은 값을 항상 반환하는 targetList에 대한 참조가 있습니다.

    그래서, 나는 이것과 같아야한다고 믿는다 :

    listItems = targetlist.getItems(query);
    


    CEWP 제시된 여기가 있습니다 다음 단계를 따르십시오.
    1. 사용자 정의 목록을 만들고 목록에 다음 새 필드를 추가하십시오.

      위도 (숫자), 경도 (숫자), 도시 (주)

    2. 자바 스크립트 저장 ( source ) 및 html ( 소스 ) 별도의 파일과 장소에 매핑을위한 코드 예를 들어 문서 라이브러리 "Nofollow"> 콘텐츠 링크 속성, 예를 들어 targetList

      ¬¸

      informate for /Geo/Shared Documents/NokiaStoresMap.htm가 실행되지 않는 경우 내 경우. 해결 방법은 명시 적으로 sp.js를로드하는 것이었기 때문에 선 라인

      ExecuteOrDelayUntilScriptLoaded(loadList,'sp.js');
      
      .

      이이 하나로 교체해야합니다 :

      LoadSodByKey('sp.js')
      ExecuteOrDelayUntilScriptLoaded(loadList,'sp.js');
      
      .

      사용량

      목록 제목은 예를 들어 URL을 통해 전달되어야합니다.

      /Geo/Pages/Default.aspx?MapData=NokiaStores
      
      .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top