Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Documentation tool: toMarkdown(json: JSON) => string module #25

Closed
gcanti opened this issue Jan 16, 2016 · 0 comments
Closed

Documentation tool: toMarkdown(json: JSON) => string module #25

gcanti opened this issue Jan 16, 2016 · 0 comments
Milestone

Comments

@gcanti
Copy link
Owner

gcanti commented Jan 16, 2016

Source

import React from 'react'
import { props, t } from 'tcomb-react'
import User from './User'

/**
 * Component description here
 * name and surname must be both nil or both specified
 * @param name - name description
 * @param surname - surname description
 */

const Props = t.refinement(t.struct({
  name: t.maybe(User.meta.props.name),
  surname: t.maybe(User.meta.props.surname)
}), (x) => t.Nil.is(x.name) === t.Nil.is(x.surname))

@props(Props)
export default class Card extends React.Component {

  static defaultProps = {
    name: 'Giulio',
    surname: 'Canti'
  }

  render() {
    return (
      <div>
        <p>{this.props.name}</p>
        <p>{this.props.surname}</p>
      </div>
    )
  }
}

Usage

var parse = require('tcomb-react/lib/parse');
var toMarkdown = require('tcomb-react/lib/toMarkdown');
var json = parse('../components/Card.js');
console.log(toMarkdown(json));

Output

# Card

Component description here
name and surname must be both nil or both specified

**Props**

- `name: String` (optional, default: `"Giulio"`) name description
- `surname: String` (optional, default: `"Canti"`) surname description

Card

Component description here
name and surname must be both nil or both specified

Props

  • name: String (optional, default: "Giulio") name description
  • surname: String (optional, default: "Canti") surname description
@gcanti gcanti added this to the 0.8.12 milestone Jan 16, 2016
gcanti added a commit that referenced this issue Jan 16, 2016
gcanti added a commit that referenced this issue Jan 16, 2016
gcanti added a commit that referenced this issue Jan 17, 2016
gcanti added a commit that referenced this issue Jan 17, 2016
gcanti added a commit that referenced this issue Jan 23, 2016
@gcanti gcanti closed this as completed in 3b5c8f2 Jan 23, 2016
gcanti added a commit that referenced this issue Jan 23, 2016
Documentation tools, fix #24, fix #25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant