appertly/hphpdoc

Hack/HHVM 和 PHP 的 API 文档生成器

安装: 41

依赖: 1

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 2

开放问题: 1

语言:Hack

0.4.0 2016-10-03 15:40 UTC

This package is not auto-updated.

Last update: 2024-09-09 06:33:17 UTC


README

Hack/HHVM 和 PHP 的 API 文档生成器

查看一些示例文档:实际上,它是我们自己的 API。请查看。

Packagist Build Status

安装

您可以使用 Composer 安装此库

$ composer require appertly/hphpdoc
  • 此项目的 master 分支(版本 0.x)需要 HHVM 3.12,并依赖于 appertly/axeappertly/cleopatrafredemmott/definition-finder

兼容性

此库的版本将符合 语义化版本控制

我们的代码旨在符合 PSR-1PSR-2PSR-4。如果您发现任何与标准兼容性相关的问题,请发送 pull request!

使用

您可以使用 -h 或 --help 标志查看所有命令行选项的列表,或者通过不带参数调用 hphpdoc 可执行文件。

Usage:  hphpdoc [options] [--] [args...]

hphpdoc generates API documentation for Hack and PHP files.

Options:
  -h --help     Show this help screen
  --version     Displays version information
  -v --verbose  Increases verbosity level (can be used more than once, e.g.
                -vvv)
  -q --quiet    Prevents any output except errors; supercedes the verbose
                setting
  -x --exclude  Excludes specific files and folders from scanning (can be used
                more than once), wildcards are not supported
  -o --output   Specifies the directory for generated documentation; defaults
                to PWD

例如

hphpdoc -v -x tests -o build/api .

PHPDoc 语法

基本上,我们试图涵盖 PSR-5 中的所有内容。此初始版本覆盖了许多标签,但并非全部。

由于 Hack 的类型提示比 PHP 5 更严格,您可以选择从您的 @var@param@return PHPDoc 标签中省略类型!

/**
 * @var You can omit the type here, or…
 */
protected string $something = "nothing";
/**
 * …you can just specify a description here. The type is detected automatically!
 */
protected Vector<string> $test = Vector{'foo'};
/**
 * This is my method.
 *
 * This is a description.
 *
 * @param $name - The name
 * @param $numbers - The numbers
 * @param $log - The log
 * @return - The thing you need. Always specify a dash before description.
 * @throws \RuntimeException if anything goes wrong
 */
public function getFoo(string $name, ConstVector<int> $numbers, Psr\Log\LoggerInterface $log): ?Foo<Bar>
{
    return null;
}

如果您的返回类型或参数类型提示是 mixed,则 hphpdoc 将回退到指定的 PHPDoc 标签类型。示例

/**
 * @return array<string>|string|null The return type
 */
function nope(): mixed
{
    return null;
}