Skip to content

Editing Living Documentation

Viljami Salminen edited this page Feb 23, 2018 · 4 revisions

System’s components are documented based on the comments in your source code and readme files that live inside /docs/. Each Element, Pattern and Template can also include a custom block called <docs/>, which is used to provide an example of the markup. Like this:

<docs>
  ```jsx
  <wrapper>I’m an example that will be shown in docs.</wrapper>
  ```
</docs>

In addition, you can include JSDoc style comment blocks inside your <script/> which will be shown in the documentation. An example:

<script>
  /**
   * A wrapper element is used to wrap elements and patterns.
   */
  export default {
    name: "Wrapper",
    version: "prototype",
    props: {
      /**
       * The html element name used for the wrapper.
       */
      type: {
        type: String,
        default: "div"
      }
    }
  }
</script>

Finally, the wrapper Element with all the documentation added:

<template>
  <component :is="type" class="wrapper">
    <slot/>
  </component>
</template>

<script>
  /**
   * A wrapper element is used to wrap elements and patterns.
   */
  export default {
    name: "Wrapper",
    version: "prototype",
    props: {
      /**
       * The html element name used for the wrapper.
       */
      type: {
        type: String,
        default: "div"
      }
    }
  }
</script>

<style lang="scss" scoped>
  .wrapper {
    @include reset;
    width: 100%;
    padding: $space-large;
  }
</style>

<docs>
  ```jsx
  <wrapper>I’m an example that will be shown in docs.</wrapper>
  ```
</docs>

To learn more about the documentation format and what you can do with it, Please refer to Vue Styleguidist’s official docs on GitHub.