承接 nochso/writeme 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nochso/writeme

Composer 安装命令:

composer require nochso/writeme

包简介

WRITEME to README: Maintain documentation using placeholders.

README 文档

README

GitHub tag write me to read me

nochso/writeme is a PHP CLI utility for maintaining README and related files.

For example the following table of contents was generated from the @toc@ placeholder in WRITEME.md.

Introduction

writeme can be considered a template engine with a focus on typical Markdown documents like readme, change logs, project documentation etc. Even though it's geared towards Markdown, other Markup languages and plain text will work.

A writeme document can contain YAML frontmatter and text content:

---
answer: 42
---
@answer@

The frontmatter placeholder @answer@ will be converted to 42 by running writeme <file>. This is pretty basic, however there are other types of placeholders you can use.

You could even write your own by implementing the Placeholder interface. For example the documentation of each placeholder is automatically generated from the PHPDocs of the placeholder classes. That way this README is easily updated.

Installation

For end-users the PHAR version is preferred. To install it globally:

  1. Download the PHAR file from the latest release.
  2. Make it executable: chmod +x writeme.phar
  3. Move it somewhere within your PATH: sudo cp writeme.phar /usr/local/bin/writeme

As local Composer development dependency per project:

composer require --dev nochso/writeme

As global Composer dependency:

composer global require nochso/writeme

Requirements

This project is written for and tested with PHP 5.6, 7.0 and HHVM.

Usage

Running writeme

If you've required nochso/writeme in your project using Composer, you can run the writeme executable PHP file located in vendor/bin:

vendor/bin/writeme

Run it without any arguments to get an overview of available arguments.

Initializing a new template

writeme comes with a template for a typical Composer based project available on Packagist. You can initialize your own WRITEME.md based on this template:

writeme --init

Simply answer the questions. Some are optional and pressing enter will either skip them or use defaults.

Some placeholders have default settings: you will be asked if you want to override these. Your custom settings will then be added to the YAML frontmatter.

Once you're done, you should have two new files. The template and the resulting output, usually WRITEME.md and README.md.

Escaping placeholders

To avoid replacing a placeholder, escape the @ characters with backslashes: \@example.escape\@.

Specifying a target file name

By default files named WRITEME* will be saved to README*. Names that are all upper/lower-case are preserved. This default behaviour can be overriden using the CLI option --target <filename> or frontmatter key target:

target: DOCS.md

Available placeholders

Frontmatter @*@

Frontmatter placeholders return values defined in the frontmatter.

You can define any kind of structure as long as it doesn't collide with the name of any other available placeholder:

---
greet: Hello
user:
    name: [Annyong, Tobias]
key.has.dots: yes
---
@greet@ @user.name.0@!
key has dots: @key\.has\.dots@

Frontmatter values are accessed using dot-notation, resulting in this output:

Hello Annyong!
key has dots: yes

Using dots in the keys themselves is possible by escaping them with backslashes. See the Dot class provided by nochso/omni.

@*@

TOC @toc@

TOC placeholder creates a table of contents from Markdown headers.

@toc@

Collects all Markdown headers contained in the document with a configurable maximum depth.

@toc.sub($maxDepth)@

@toc.sub@ collects Markdown headers that are below the placeholder and on the same or deeper level.

If there's a header above the placeholder, its depth will be used as a minimum depth. If there's no header above the placeholder, the first header after the placeholder will be used for the minimum depth. There is currently no maximum depth for @toc.sub@.

e.g.

# ignore me

@toc.sub@
## sub 1
# ignore me again

is converted into

# ignore me
- [sub 1](#sub-1)
## sub 1
# ignore me again
  • $maxDepth = 0 int
    • How many levels of headers you'd like to keep. Defaults to zero, meaning all sub-headers are kept.

Default options

toc:
    max-depth: 3
  • toc.max-depth
    • Maximum depth of header level to extract.

API @api@

API creates documentation from your PHP code.

By default it will search for all *.php files in your project excluding the Composer vendor and test* folders.

Available template names:

  • summary - Indented list of namespaces, classes and methods including the first line of PHPDocs.
  • short - Indented list of namespaces and classes including the first line of PHPDocs.
  • full - Verbose documentation for each class and methods.

@api($templateName)@

  • $templateName string
    • 'summary', 'short' or 'full'

Default options

api:
    file: ['*.php']
    from: [.]
    folder-exclude: [vendor, test, tests]
  • api.file
    • List of file patterns to parse.
  • api.from
    • List of folders to search files in.
  • api.folder-exclude
    • List of folders to exclude from the search.

Changelog @changelog@

Changelog fetches the most recent release notes from a CHANGELOG written in Markdown.

This placeholder is intended for changelogs following the keep-a-changelog conventions. However it should work for any Markdown formatted list of releases: each release is identified by a Markdown header. What kind of header marks a release can be specified by the changelog.release-level option.

@changelog@

Default options

changelog:
    max-changes: 2
    release-level: 2
    shift-level: 0
    file: CHANGELOG.md
    search-depth: 2
  • changelog.max-changes
    • Maximum amount of releases to include.
  • changelog.release-level
    • The header level that represents a release header.
  • changelog.shift-level
    • Amount of levels to add when displaying headers.
  • changelog.file
    • Filename of the CHANGELOG to extract releases from.
  • changelog.search-depth
    • How deep the folders should be searched.

Badge @badge@

@image($imageUrl, $altText, $url)@

  • $imageUrl string
    • URL to a badge image.
  • $altText string
    • Alternative text for image.
  • $url = NULL string|null
    • Optional URL the image will link to. If null, no link will be created.

@badge($subject, $status, $color, $altText, $url)@

Badge creation via shields.io.

  • $subject string
    • Subject to the left of the badge.
  • $status string
    • Status to the right of the badge.
  • $color = 'lightgrey' string
    • Optional status color. Defaults to lightgrey. Can be any hex color, e.g. 0000FF or one of the following: brightgreen, green, yellowgreen, yellow, orange, red, lightgrey or blue.
  • $altText = NULL string|null
    • Optional alternative text for image. Defaults to subject - status.
  • $url = NULL string|null
    • Optional URL the badge will link to. If null, no link will be created.

@badge.writeme@

Bonus badge for mentioning writeme.

@badge.travis($userRepository, $branch)@

Travis CI build status.

  • $userRepository = NULL string|null
    • User/repository, e.g. nochso/writeme. Defaults to composer.name
  • $branch = NULL string|null
    • Optional branch name.

@badge.license($userRepository)@

  • $userRepository = NULL

@badge.scrutinizer($userRepository, $branch)@

scrutinizer.

  • $userRepository = NULL null
    • Github user/repository.
  • $branch = NULL null

@badge.coveralls($userRepository, $branch)@

  • $userRepository = NULL

  • $branch = NULL

@badge.tag($userRepository)@

  • $userRepository = NULL

License

nochso/writeme is released under the MIT license. See the LICENSE for the full license text.

nochso/writeme 适用场景与选型建议

nochso/writeme 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nochso/writeme 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nochso/writeme 我们能提供哪些服务?
定制开发 / 二次开发

基于 nochso/writeme 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 112
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-14