Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Add markdown code tabs extension #68

Closed
froschdesign opened this issue Oct 10, 2018 · 2 comments
Closed

Add markdown code tabs extension #68

froschdesign opened this issue Oct 10, 2018 · 2 comments
Assignees
Milestone

Comments

@froschdesign
Copy link
Member

froschdesign commented Oct 10, 2018

Problem

At the moment the documentation often only describes the standalone use of a component. Concrete examples are missing how the end user can use the component in his application.

Suggestion

Besides longer examples of integrations which needs extra pages in the documentation, we should also add an option for simpler code blocks. This can be done with a tabbed navigation; short "tabs".

Examples

  • mvc-based and expressive-based applications (like controller-action and handler)
  • different renderer (like Twig, Plates, zend-view)
  • usage standalone or embedded in a class (like Zend\Db\Sql\Sql as standalone or in a TableGateway class)
  • array notation vs. usage with methods in forms, validators, filters, etc.

Implementation

Markdown extension

The extension "Code Tabs" for Python-Markdown allows us to create code examples for different uses and application integrations. This extension comes with ready-to-use template for the CSS framework Bootstrap.

We must extend the configuration for MkDocs: (mkdocs.yml)

markdown_extensions:
    - markdown_fenced_code_tabs:
        template: bootstrap3
    - markdown.extensions.codehilite:
        use_pygments: False

Example

```php fct_label="Standalone Use"
$sql    = new Zend\Db\Sql\Sql($adapter, 'foo');
$select = $sql->select();
$select->where(['id' => 2]);
```
```php fct_label="TableGateway Use"
$select = $this->getSql()->select();
$select->where(['id' => 2]);
```

(GitHub ignores the extra markup fct_label in the preview.)

Preview

tabs

Documentation: https://yacir.github.io/markdown-fenced-code-tabs/

Bootstrap component

https://getbootstrap.com/docs/3.3/components/#nav-tabs

@weierophinney
Copy link
Member

Addressed with #70; documentation can now start using nav tabs for code examples.

:octocat: Sent from GH.

@froschdesign
Copy link
Member Author

@weierophinney
I will create a documentation guide that covers features like this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants