定制 projektmotor/documentationbundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

projektmotor/documentationbundle

最新稳定版本:v0.2.7

Composer 安装命令:

composer require projektmotor/documentationbundle

包简介

Symfony2 markdown based documentation bundle

README 文档

README

Symfony2 Bundle to build simple Markdown based documentations (thanks to KnpMarkdownBundle & KnpMenuBundle).

Markdown syntax: cheatsheet

Features

  • filesystem based for simple handling (create markdown-file, request uri, ready!)
  • generate menus (KnpMenu) by simply parsing a toc-file (table of content)
  • link rewriting: links could be written absolute to documentation root, bundle rewrites these links to be accessable by public urls
  • image url rewriting: bundle is publishing the images to the configured path and rewrites urls, similar to links

Dependencies

Install

  • Install package via composer:
...
"projektmotor/documentationbundle" : "~0.1",
...
  • Activate in AppKernel:
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // activate bundle in AppKernel
        new Pm\DocumentationBundle\PmDocumentationBundle(),
        
        // if not yet done
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
    );
}
  • Include routing:
# e.g. app/config/routing.yml
pm_documentation:
    resource: "@PmDocumentationBundle/Resources/config/routing.yml"
    prefix:   /documentation
  • OPTIONAL - Set documentation root dir & template (if you do not want to use the default path):
# e.g. app/config/config.yml
pm_documentation:
    doc_path:   '/path/to/doc'
    image_dest: '/web/images/doc'
    view:       'AppBundle::layout.html.twig'
  • NOTE: the template (view) MUST CONTAIN a block called content where the parsed markdown is rendered in.
  • NOTE: image destination path must be writeable by the web server user (e.g. www-data)

Usage

Directory Structure

  • let`s say your documentation-root is at /my/doc
  • first level subdirectories divide different languages from each other
    • /my/doc/en
    • /my/doc/de
    • ...
  • every dir behind the language-dirs MUST contain an index.md (see Requesting a Page)
  • /my/doc/en/index.md
  • /my/doc/en/chapter_1/index.md
  • ...
  • the language-dirs SHOULD contain a toc.md (depending on your need of a menu)
  • /my/doc/en/toc.md
  • /my/doc/de/toc.md
  • ...

Requesting a Page

Assuming you want to render the markdown file /path/to/doc/en/chapter_1/first-steps.md in your browser, just call http://example.com/documentation/en/chapter_1/first-steps.

Structure:

  • documentation : the route prefix (could be set in routing)
  • en : the locale
  • chapter_1/first_steps : path to markdown file

If you request a folder instead of specific markdown-file, the index.md file of the folder is used. Requesting http://example.com/documentation/en/chapter_1 would end up in rendering the /path/to/doc/en/chapter_1/index.md

Including the (Sub-) Menu:

  • inject menu helper to you Knp MenuBuilder:
services:
    app.menu_builder:
        class: AppBundle\Menu\MenuBuilder
        arguments:
            - @knp_menu.factory
            - @pm_documentation.menu_helper
class MenuBuilder
{
    private $menuBuilderHelper;
    
    public function __construct(FactoryInterface $factory, MenuBuilderHelper $subMenuBuilder)
    {
        $this->factory = $factory;
        $this->menuBuilderHelper = $subMenuBuilder;
    }
}
  • add menu (based on toc.md)
class MenuBuilder
{
  // ....
  public function createMainMenu(RequestStack $requestStack)
  {
      $menu = $this->factory->createItem('root');

      // adding documentation menu as submenu
      $menu->addChild('Documentation', array(...));
      $this->subMenuBuilder->buildDocumentationMenu($menu['Documentation']);

      // OR adding as first-level menu
      $this->subMenuBuilder->buildDocumentationMenu($menu);
  }
  
  // ....
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-18