Coder Social home page Coder Social logo

propellant / doctor Goto Github PK

View Code? Open in Web Editor NEW
227.0 7.0 21.0 410 KB

quick and easy documentation of Vue.js components - DEPRECATED

License: MIT License

JavaScript 58.55% Vue 26.26% Makefile 3.99% CSS 11.20%
vuejs documentation props component

doctor's Introduction

propdoc Build Status

quick and easy documentation of Vue.js components

installation

npm install --save propdoc

example output

This example was solely generated based on the extra fields described below.

screenshot

features

propdoc proposes a new way of documenting Vue components, by including some (or all) of the documentation in the component itself.

Benefits:

  • props can be directly annotated, making documentation essentially the same as commenting a prop
  • Documentation can live directly in the component - thus centralizing the documentation and hopefully helping the development/documentation cycle

Downsides:

  • If all documentation is built into the options object, the component will use additional space
    • This can be mitigated by externalizing the larger proposed keys such as description and token

new keys for your components

This example showcases all of what propdoc would parse, however, none are required to be used and will not be output if absent.

export default {
  name: 'checkbox',
  introduction: 'an amazing checkbox',
  description: `
  This \`checkbox\` is amazing, you should _check_ it out.
  `,
  token: "<checkbox label='foo'></checkbox>",
  props: {
    label: {
      type: String,
      default: '',
      note: "a label to be appended after the checkbox"
    }
  }
}

note

note is used alongside expanded (object-style) props to describe that prop in more detail

introduction

a brief summary of what the component is or does

description

a more in-depth documentation of the component, will be parsed using Markdown. Note that code will need to be escaped if it's inside of a Javascript string literal.

token

a quick example of the component's actual use, great for providing a way to quickly copy/paste in the future

use in your documentation

<script>
import propDoc from 'propdoc'
import myComponent from './myComponent.vue'

export default {
  components: { propDoc },
  // bind your component to use propdoc's native template output
  data() {
    return { documentMe: myComponent }
  },
  // or call getDoc() and use the same data in your own template
  computed: {
    myComponentDoc() { return propDoc.getDoc(myComponent) }
  }
}
</script>

<template>
  <section>
    <prop-doc :component="documentMe"></prop-doc>
    <div>
      <h1>{{ myComponentDoc.name }}</h1>
      <p>{{ myComponentDoc.introduction }}</p>
    </div>
  </section>
</template>

props

  • component: required and should be the component object itself
  • documentation: optional, can be any subset of component, and will take precedence; useful for two functions
    • if the component's name or other fields should be output differently for documentation
    • for the optional documentation fields, as these will cause some additional space to be used by your components if not separated

slots

Two named slots are available for adding content to what propdoc emits

  • pre-use will add content before the description and token fields
  • pre-props will add content before the prop tables are emitted

propDoc.getDoc

available in v0.8 onward

propDoc.getDoc(component, documentation)

  • merges the arguments passed to it, then processes them as described above in keys
  • the props object will be converted into an array instead of an object to simplify parsing in your template
    • essentially this means you can do v-for="prop in myDocumentedComponent.props" and then prop.name instead of having to separate out the key/value

doctor's People

Contributors

antoumpas avatar maurop123 avatar pearofducks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.