awema-pl/module-docs

Package for wiki output

v1.0.8 2020-11-23 12:51 UTC

This package is auto-updated.

Last update: 2024-04-14 23:34:52 UTC


README

Coverage report Build status Composer Ready Downloads Last version

Awema packages documentation reader

Installation

Via Composer

$ composer require awema-pl/module-docs

The package will automatically register itself.

You can publish the views with:

php artisan vendor:publish --provider="AwemaPL\Docs\DocsServiceProvider" --tag="views"

You can publish the config file with:

php artisan vendor:publish --provider="AwemaPL\Docs\DocsServiceProvider" --tag="config"

Adding docs routes

Add to routes\web.php

Docs::routes();

Examples of use

use Docs;

Docs::all($withDocs = true);

Docs::get(['package1' => ['1.0', '2.6'], 'package2' => '1.3', 'package3'], 'package4', $withDocs = true);

Docs::package('package1', $withDocs = true);

Docs::versions('package1', $withDocs = true);

Docs::version('package1', '1.0', $withDocs = true);

Docs::files('package1', '1.0', $withDocs = true);

Docs::file('package1', '1.0', 'file.md');

Docs::fileContent('package1', '1.0', 'file.md');

Docs::list();

Docs::list('package1');

Docs::list('package1', '1.0');

Docs::list('package1', '1.0', 'file.md');

Methods

all()

Docs::all($withDocs = true);

Output:

[
  [
    "name" => "package1",
    "versions" => [
      [ 
        "name" => "1.0",
        "files" => [
          [
            "name" => "index.md",
            "content" => "# Title"
          ],
          [
            "name" => "doc1.md",
            "content" => "Doc 1 content"
          ]
        ]
      ],
      ...
      [ 
        "name" => "2.6",
        "files" => [ ... ]
      ]
    ]
  ],
  ...  
  [
    "name" => "package4",
    "versions" => [ ... ]
  ]
]

Input param $withDocs is bollean, optional and is true by default.

if $withDocs == false file content will be null

get()

Docs::get(['package1' => ['1.0', '2.6'], 'package2' => '1.3', 'package3'], 'package4', $withDocs = true);

Last bool param $withDocs is optional and is true by default

Method output is the same as for all(), but will contain only specified in args packages and versions.

If packages are not listed result will contain all packages.

If versions for specified package is not listed result will contain all versions for that package

package()

Docs::package('package1', $withDocs = true);

Output:

[
  "name" => "package1",
  "versions" => [
    [ 
      "name" => "1.0",
      "files" => [
        [
          "name" => "index.md",
          "content" => "# Title"
        ],
        [
          "name" => "doc1.md",
          "content" => "Doc 1 content"
        ]
      ]
    ],
    ...
    [ 
      "name" => "2.6",
      "files" => [ ... ]
    ]
  ]
]

If package is not in the docs, result will be null.

Last bool param $withDocs is optional and is true by default.

If $withDocs == false file content will be null.

versions()

Docs::versions('package1', $withDocs = true);

Output:

[
  [ 
    "name" => "1.0",
    "files" => [
      [
        "name" => "index.md",
        "content" => "# Title"
      ],
      [
        "name" => "doc1.md",
        "content" => "Doc 1 content"
      ]
    ]
  ],
  ...
  [ 
    "name" => "2.6",
    "files" => [ ... ]
  ]
]

If package is not in the docs, result will be null.

Last bool param $withDocs is optional and is true by default.

If $withDocs == false file content will be null.

version()

Docs::version('package1', '1.0', $withDocs = true);

Output:

[ 
  "name" => "1.0",
  "files" => [
    [
      "name" => "index.md",
      "content" => "# Title"
    ],
    [
      "name" => "doc1.md",
      "content" => "Doc 1 content"
    ]
  ]
]

If package or version is not in the docs, result will be null.

Last bool param $withDocs is optional and is true by default.

If $withDocs == false file content will be null.

files()

Docs::files('package1', '1.0', $withDocs = true);

Output:

[
  [
    "name" => "index.md",
    "content" => "# Title"
  ],
  [
    "name" => "doc1.md",
    "content" => "Doc 1 content"
  ]
]

If package or version is not in the docs, result will be null.

Last bool param $withDocs is optional and is true by default.

If $withDocs == false file content will be null.

file()

Docs::file('package1', '1.0', 'file.md');

Output:

[
  "name" => "index.md",
  "content" => "# Title"
]

If package or version or file is not in the docs, result will be null.

fileContent()

Docs::fileContent('package1', '1.0', 'file.md');

Result is file content string or null if file does not exists

list()

Docs::list();

Output is array of packages names

[
  "package1",
  "package2",
  ...
  "package6"
]

Docs::list('package1');

Output is array of package versions names

[
  "0.1",
  "0.2",
  ...
  "2.18"
]

If package is not in the docs, result will be null.

Docs::list('package1', '1.0');

Output is array of package version files names

[
  "index.md",
  "doc1.md",
  ...
  "doc4.md"
]

If package or version is not in the docs, result will be null.

Docs::list('package1', '1.0', 'file.md');

Result is file content string or null if file does not exists

Testing

You can run the tests with:

composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.