Code Monkey home page Code Monkey logo

scribe's Introduction

Scribe โ€“ A syntax for documenting CSS

What is Scribe?

Scribe is a markup syntax for CSS which allows an interpreter to render documentation for a given stylesheet.

Why Scribe?

Documenting CSS is hard. It normally involves a lot of manual maintenance and editing. Scribe automates documentation to let you focus on making things.


Getting started

Serving Scribe locally

git clone [email protected]:heroku/scribe.git
cd scribe
brew install devd
devd -ol public_html

Generating new documentation/rebuilding docs

./scribe --input=/Path/To/purple3/src/

Syntax

INTRODUCTION

The simplest possible Scribe block consists of the @scribe keyword and <template>:

/*
@scribe Text colors

<template>
    <span class="{{class}}">Hello</span>
</template>
*/

.red {
   text-color: red;
}

.blue {
   text-color: blue;
}

Running Scribe on this file will produce the following HTML:

<span class="red">Hello</span>
<span class="blue">Hello</span>

You'll notice that {{class}} in our template is replaced with the CSS classes below the Scribe comment block.

Multiple scribe blocks

Multiple Scribe blocks can be inserted into a CSS document. Scribe will document all the classes following the block until either;

  • Another Scribe block is found
  • Any CSS comment is found
  • End of file is reached

For example; we want to document our green text color on a black background to make it easier to read.

/*
@scribe Text colors

<template>
    <span class="{{class}}">Hello</span>
</template>
*/

.red {
   text-color: red;
}

.blue {
   text-color: blue;
}

/*
@scribe Text colors on dark

<template>
    <div class="bg-black">
        <span class="{{class}}">Hello</span>
    </div>
</template>
*/

.yellow {
    text-color: yellow;
}

The HTML produced now will be;

<span class="red">Hello</span>
<span class="blue">Hello</span>
<div class="bg-black">
    <span class="yellow">Hello</span>
</div>

Markdown in scribe

Sometimes it's nice to document things with a sentence or two about how to use the CSS class in question.

Scribe allows you to write Markdown as part of the Scribe block which will be parsed and displayed next to the documented CSS.

Write your markdown between <md> tags like so;

/*
@scribe Text colors

<md>
# This is a heading
This is a paragraph

* This
* Is 
* A
* List
</md>

<template>
    <span class="{{class}}">Hello</span>
</template>
*/

Be careful not to indent your markdown as indentation has special meaning to the markdown parser.

Ignoring css selectors

We've documented three of our text colors but we still have another two in our file that we don't want to document yet. Let's stop Scribe from reading them with a /* @scribe nodoc */ comment block.

/*
@scribe Text colors

<template>
    <span class="{{class}}">Hello</span>
</template>
*/

.red {
   text-color: red;
}

.blue {
   text-color: blue;
}

/*
@scribe Text colors on dark

<template>
    <div class="bg-black">
        <span class="{{class}}">Hello</span>
    </div>
</template>
*/

.yellow {
    text-color: yellow;
}

/* @scribe nodoc */

.green {
    text-color: green;
}

.orange {
    text-color: orange;
}

scribe's People

Contributors

almonk avatar

Watchers

 avatar  avatar

scribe's Issues

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.