wn/mate

一个从PHPDoc注释生成文档和测试的工具。

1.0.0 2018-07-24 01:40 UTC

This package is auto-updated.

Last update: 2024-09-24 05:30:35 UTC


README

Build Status Coverage Status Donate Software License

内容

什么是 Mate?

Mate 是一个用于从PHPDoc注释为功能性库生成文档和测试的工具。

什么是 PHPDoc 注释?

它是一种像这样的注释

/**
 * Description here.
 * @tag value
 * @other-tag some other value
 */

那么,你说的“功能性库”是什么意思呢?

我的意思是,一组纯函数和类型定义。测试纯函数很容易,可以在注释内完成。测试有副作用或改变其内部状态的函数会变得复杂,并且目前还不是 Mate 的功能(?)。

嗯,那么你的意思是我不能在包含类或非纯函数的项目中使用 Mate 吗?

您可以在任何项目中使用 Mate 生成纯函数的文档和测试。这不会影响您项目的其他部分。Mate 还可以用来监视源文件的变化,并在文件更改时运行 phpunit

要求

  • PHP 7.1+

安装

将其作为开发依赖项安装

composer require wn/mate --dev

屏幕截图

Generating function tests

Generating function documentation

Generating type documentation

命令行选项

运行 mate --help 显示命令行选项

Mate version 1.0.0-alpha

a tool to generate documentation and tests from PHPDoc comments.

Syntax: [options] configPath
Arguments:
    configPath string Path to the config file. (default: "mate.json")
Options:
    --dont-run-tests Don't run phpunit after the build.
    --watch Watch source files for changes.
    --no-cache Don't use cache. Should not be combined with --watch.
    --no-tests Don't generate test files.
    --no-docs Don't generate documentation files.
  • --dont-run-tests:默认情况下,Mate 会在每次构建或文件更改后运行 phpunit
  • --watch:使用此选项,Mate 会监视源文件的变化,并生成更改后的测试和文档。它还会在每次更改后运行 phpunit
  • --no-cache:默认情况下,Mate 会创建一个名为 mate.lock 的文件并将其用作缓存。这有助于在监视文件时,不重新生成所有测试和文档。如果不想让 Mate 使用缓存,请使用此选项。

配置文件

以下是默认配置文件

{
  "srcDir": "src",
  "testsDir": "tests",
  "docsDir": "docs",
  "testCaseClass": "\\Wn\\Mate\\Classes\\TestCase",
  "cachePath": "mate.lock"
}