Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

docma-template-zebra

onury8.6kMIT2.3.1

Zebra - Default template for Docma. https://github.com/onury/docma

docma, template

readme

Zebra — Template for Docma

This is the default template for Docma; with a side-bar symbols menu, search and navigation features; and a beautiful layout.

Built with Docma using Zebra Template
click to view live

Usage

  1. Make sure you have the latest Docma installed.
  2. Although Zebra is installed together with Docma, you can still install/update this template via npm: npm i docma-template-zebra -D
  3. Set template.path to "default" or "zebra" or omit it in your build configuration (docma.json).
  4. Configure and set template.options as described below.

Template Options

Template specific options that can be used when building your documentation with Zebra.

Option Type Description
title String|Object Title to be set both on the navbar and sidebar. If you want to set a link for these titles, pass an object. Default: ""
Note: Don't confuse this with document title (tag) which is set via app.title in the build configuration.
↳ title.label String Title to be set both on navbar and sidebar. Default: ""
↳ title.href String Link to be set for both navbar and sidebar titles. Default: "#"
logo String|Object URL of your logo to be used both in the sidebar and navbar, on the left of the title. If you need to set separate logos for dark (sidebar) and light (navbar) backgrounds, set this to an object. Recommended size of a logo image is 120 x 120 pixels. Default: null
↳ logo.dark String URL for dark logo. Default: null
↳ logo.light String URL for light logo. Default: null
sidebar Object|Boolean Contains settings for the sidebar that lists the documentation symbols; as an outline menu. To simply toggle this with default settings, pass a boolean. For detailed configuration pass an object. Default: true
↳ sidebar.enabled Boolean Whether to the sidebar should be visible/enabled... Default: true
↳ sidebar.collapsed Boolean Whether to collapse the sidebar initially by default, on document load. Default: false
↳ sidebar.outline String Indicates the outline style for the sidebar symbols. If set to "flat" symbols are listed with their long names. If set to "tree", symbols are listed with their short names; as an indented tree, depending on their hierarchical position. Default: "tree"
↳ sidebar.toolbar Boolean Whether the toolbar below the sidebar search-box should be shown. This toolbar provides buttons for switching between outlines, quick-filtering symbols by symbol-kind, etc... Default: true
↳ sidebar.itemsFolded Boolean Indicates whether to initially fold symbol items with child members, in the sidebar. Default: false
↳ sidebar.itemsOverflow String Specifies how to fit overflowing sidebar items. Either set to "crop" (crops the item and reveals on hover), or "shrink" (decreases font-size until it fits). Default: "crop"
↳ sidebar.animations Boolean Whether CSS transitions and animations are enabled for sidebar and listed symbols. Default: true
↳ sidebar.badges Boolean|String Whether to show symbol badges (that indicate member type and symbol scope) within the sidebar. If set to false, will be used as bullets, instead of badges. Or you can set a string for custom bullets. Default: true
↳ sidebar.search Boolean Whether to enable the search box within the sidebar. For this to be visible, sidebar should be enabled. Default: true
symbols Object Contains settings for symbol definition documentation. Default: {}
↳ symbols.autoLink Boolean|String Specifies whether documented types should be auto-linked to their sources. Set to "internal" paths (i.e. Docma route if type/object definition is within the generated docs) or "external" (MDN docs if it's a JS or Web-API built-in type/object); or true for both. Default: true
↳ symbols.meta Boolean Whether to add meta information at the end of each symbol documentation such as code file name and line number. Default: false
↳ symbols.params String Specifies the layout style for documented parameters of a symbol. Possible values are "list" or "table". Default: "list"
↳ symbols.props String Specifies the layout style for documented properties of a symbol. Possible values are "list" or "table". Default: "list"
↳ symbols.enums String Specifies the layout style for documented properties of an enumeration symbol. Possible values are "list" or "table". Default: "list"
contentView Object Contains settings for content view, which is generated from markdown or HTML files.
↳ contentView.bookmarks Boolean|String Whether to automatically add bookmark links for headings. In order to customize the list of heading tags, set to a comma separated tag name list. e.g. "h1,h2". Default: false
↳ contentView.faLibs String|Array FontAwesome icon libraries to be included with the generated output. Set to "all" to include all libraries. To include an individual library; set to "solid", "regular" or "brands". Or you can set to a combination of libraries. e.g. "solid,brands". Set to null to exclude FontAwesome from the output. Default: "all"
↳ contentView.faVersion String FontAwesome icon library version to be used. Default: "5.5.0"
navbar Object|Boolean Contains settings for the navigation bar on top of the main document. This is useful if you have extra views to navigate to. To simply toggle this with default settings, pass a boolean. For detailed configuration pass an object. Default: {}
↳ navbar.enabled Boolean Whether to the navbar should be visible/enabled... Default: true
↳ navbar.fixed Boolean Whether navbar should be fixed to top of the page. Default: true
↳ navbar.dark Boolean Whether to enable dark theme on navbar. Default: false Note: If this is enabled, you don't need to set path for a dark logo.
↳ navbar.animations Boolean Whether CSS transitions and animations are enabled for navbar and listed symbols. Default: true
↳ navbar.menu Array List of navigation menu items that builds the navbar and submenu items. See Navigation Menu below. Default: []

Linked labels that build the navigation menu on the top bar of the document. Each item is an arbitrary Object with the following properties.

Property Type Description
label String Label of the navigation item. Try keeping this short. Default: ""
href String Sets the link of the navigation item. Either a bookmark, a relative or external link. Default: "#"
target String Sets the anchor target option. e.g. "_blank" to open the link in new/blank page. Default: undefined
iconClass String One of FontAwsome (v5) Free icon CSS classes. e.g. "fab fa-github". You can combine this with a class that define the size of the icon such as "fab fa-github fa-w-16". See this on how to use FontAwsome v5 icons for details. Default: undefined
chevron Boolean Toggles the visibility of the dropdown arrow for the corresponding item. Default: true
items Array Sub-items for this navigation item. You can use label, href and target options. You can also use an additional separator option, which places a horizontal line within the submenu. e.g. { separator: true }. Default: undefined

Usage with Docma

Template options are defined within the build configuration. i.e. in a docma.json file.

{
    "template": {
        // Docma Template to be used. 
        // Either a path, module name or "default"
        "path": "zebra",
        // Zebra template-specific options
        "options": {
            "title": {
                "label": "My Library",
                "href": "/base/"
            },
            "logo": {
                "dark": "img/dark-logo.png",
                "light": "img/light-logo.png"
            },
            "sidebar": {
                "enabled": true,
                "outline": "tree",
                "collapsed": false,
                "toolbar": true,
                "itemsFolded": false,
                "itemsOverflow": "crop",
                "badges": true,
                "search": true,
                "animations": true
            },
            "symbols": {
                "autoLink": true,
                "params": "list",
                "enums": "list",
                "props": "list",
                "meta": false
            },
            "contentView": {
                "bookmarks": "h1,h2,h3",
                "faLibs": "solid,regular,brands"
            },
            "navbar": {
                "enabled": true,
                "dark": false,
                "animations": true,
                "menu": [
                    {
                        "label": "Docs",
                        "iconClass": "fas fa-book",
                        "href": "./"
                    },
                    {
                        "label": "Demos",
                        "iconClass": "fas fa-mouse-pointer",
                        "href": "?content=demos"
                    },
                    {
                        "label": "Download",
                        "iconClass": "fas fa-cloud-download-alt",
                        "items": [
                            {
                                "label": "v0.5.0-pre",
                                "href": "https://github.com/user/repo/archive/v0.7.0-pre.zip"
                            },
                            { "separator": true },
                            {
                                "label": "v1.0.0",
                                "href": "https://github.com/user/repo/archive/v1.0.0.zip"
                            }
                        ]
                    },
                    {
                        "label": "GitHub",
                        "iconClass": "fab fa-github",
                        "href": "https://github.com/user/repo",
                        "target": "_blank"
                    }
                ]
            }
        }
    },
    // other build configuration options
    // src, dest, app, jsdoc, markdown, debug, etc...
}

Then you can build your documentation with these customized template options.

Docma.create()
    .build('path/to/docma.json')
    .then(() => {
        console.log('Documentation is built successfully.');
    })
    .catch(err => {
        console.log(err);
    });

...or build via CLI:

docma -c path/to/docma.json

Changelog

See CHANGELOG.
Note: If you're upgrading from Zebra v1.x to v2.x, there are some breaking changes.

License

MIT.

Emoji shortcuts used in source markdown files are parsed into twemoji. Graphics and icons licensed under CC-BY 4.0. See FontAwesome license.

changelog

Zebra Changelog

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

2.3.1 (2019-01-08)

Fixed

  • An issue where some special characters within the location hash would cause an error.

2.3.0 (2018-12-04)

Added

  • JSDoc @default tag support for symbols. Fixes #60.
  • New option contentView.faLibs that defines FontAwesome libraries to be included, such as solid, regular, brands. Set to null to completely exclude FontAwesome from the output. See Zebra documentation. Fixes #63.
  • New option contentView.faVersion that defines FontAwesome icon library version to be included.

Changed

  • Minor style revisions.
  • Updated dependencies to latest versions.

2.2.0 (2018-11-18)

This version of Zebra template still supports Docma 2.0.0 and later.

Added

  • Support for collapsable markdown (i.e. with <details> and <summary> tags).

Changed

  • Improved support for constant symbols.
  • Default template title is now "Documentation". Set template.options.title to empty string to remove.

Fixed

2.1.0 (2018-04-14)

Added

  • Partial support for TypeScript-style type notation. e.g. Promise<Number> or Number[], etc...

Fixed

  • An issue where deeper levels of tree nodes were not properly aligned, when sidebar.outline is set to "tree".
  • An issue where some symbol names were unnecessarily scroll-animated on hover. Firefox was affected.
  • An issue where multiple return types were listed out of style.

Changed

  • When sidebar.itemsOverflow is set to "crop" (default); symbol names are faded-out on their edges, instead of using ellipsis (which behaves differently on browsers).

2.0.0 (2018-04-12)

This is a big release with some breaking changes.
Please read this changelog thoroughly before updating your template configuration.

Added

  • Support for @example <caption>Title</caption>. Fixes issue #14.
  • Support for @hideconstructor tag. Fixes issue #21.
  • Support for @event, @emits (and alias @fires) tags. Fixes issue #35.
  • Support for @generator and @yields tags.
  • Support for rest parameters (i.e. ...args).
  • Support for @since tag.
  • Support for folding child members of parent symbols. Added template option sidebar.itemsFolded (boolean) for setting the initial state. Fixes issue #26.
  • Template option sidebar.toolbar (boolean) that toggles a tiny toolbar below the search box, for switching symbol list outline or quick-filtering symbols by symbol-kind. Enabled by default.
  • Template option logo (String|Object) specifies the URL of your logo. If you need separate logos for dark and light backgrounds set this to an object. i.e. { dark: String, light: String }. Recommended size of a logo image is 120 x 120 pixels.
  • Template option symbols.autoLink (Boolean|String) specifies whether documented types should be auto-linked to internal paths (i.e. Docma route if type/object definition is within the generated documentation) or external URLs (MDN docs if it's a JS or Web-API built-in type/object such as String); or both. Thanks to @warpdesign for the idea.
  • Template options symbols.params, symbols.props and symbols.enums all taking a string value, either "list" (default) or "table"; defining the layout style for parameters, properties and enumerations. If you like the design in previous versions, set these to "table".
  • Template option sidebar.itemsOverflow (String) that specifies how to fit overflowing sidebar items. Either set to "crop" (default, crops the item and reveals on hover), or "shrink" (decreases font-size until it fits).
  • Template option sidebar.animations and navbar.animations (Boolean) specifies whether CSS transitions and animations should be enabled for navbar, sidebar and listed symbols.
  • Template option navbar.fixed (Boolean) toggles between fixed and static navbar.
  • Template option navbar.dark (Boolean) enables dark theme for the navbar.
  • chevron (Boolean) option for navbar menu items. Set this to false if you don't want the dropdown arrow to be visible for that item.
  • Template option contentView.bookmarks option (Boolean|String) which automatically adds bookmark links to headings to content generated from markdown files. Default: false.
  • generator badge for generator functions.

Fixed

  • Some spacing issues with class descriptions. Empty tables are auto-removed now.
  • A JSDoc issue where the constructor would be incorrectly marked as alias.
  • An anchor/bookmark issue with multiple symbols having the same id.
  • Sub-symbols that are listed in a table, will not wrap to new line anymore.
  • An issue where the (heading) title would be hidden under the nav-bar when navigated via a local bookmark on a page, generated from a markdown file. Also improved spacing for headings.
  • An issue where the page would not scroll/jump to the bookmark on initial load; when the URL has a location hash.
  • Pre/code elements not to wrap content. Now, horizontally scrollable (like on GitHub).
  • An issue where it would throw if a symbol paramter with no description is parsed.
  • An issue with sidebar symbol names auto-resizing incorrectly in some cases. Also improved performance by caching font-size for each item.
  • hidden meta issue. If symbol had no class description, tags such as @author, @version and @copyright would not be shown.
  • Sidebar scrollbars that were not fully visible.
  • Some issues with navbar margins when sidebar is disabled.
  • Sidebar and navbar title so that they allow longer strings without breaking.

Changed

  • Default template finally has a name :) - Zebra.
  • BREAKING: You need Docma v2+ for latest Zebra template to work.
  • Improved symbol listing styles and performance. Using CSS transitions instead of JS manipulation. Also; when search is active, outline is temporarily set to "flat" so that you see the parent of the symbol. When search box is cleaned, it's set back to the initial template setting. (e.g. "tree" if set).
  • Improved @example outputs. If there are multiple examples for a symbol, they will be numbered now.
  • Improved nested bullet list spacing, for better readability.
  • Improved UI and responsive layout. On small screens, sidebar auto-collapses; top navbar turns into hamburger menu. Also, truly printable.
  • Improved template option .badges (default: true) to also accept a string value for custom bullets instead of badges.
  • Improved template option .title to also accept an object { label:String, href:String } so you can link it.
  • Various other improvements and clean up.

Deprecated

  • The template options object structure is changed and a couple of options are renamed. Old structure is still supported and it won't break anything but this support will be removed in future versions. See documentation for the new & improved structure.

Removed

  • BREAKING: icomoon selection of icons (and ico- CSS prefix) in favor of FontAwsome (v5) and SVG icons support.
  • Bootstrap and its dependencies (css and js). Also, cleaned up all unused styles.