Git Product home page Git Product logo

flask-styleguide-example's Introduction

Living Styleguide

Example of living Styleguide made with Flask-Styleguide and Frozen-Flask. This guide describes how to generate your own styleguide for any flask application.

  • Use KSS to document your stylesheets. KSS is documentation syntax for any flavor CSS. It's human readable, machine parsable, and easy to remember. Flask-Styleguide looks for any KSS formated documentation in static directories of your application and registered blueprints (if any).

    // A standard, but classy, button used widely for submit forms and
    // to complete other app actions.
    //
    // :hover - Hover state.
    // :active - When the button is pressed.
    // :focus - When the button is focused.
    // :disabled - Disabled state.
    // .is-disabled - Same as above.
    //
    // Styleguide 2.1.
  • Define endpoint for your styleguide in application:

    @app.route('/styleguide/')
    def styleguide():
        return render_template('styleguide.html')
  • The new jinja tag styleguide becomes available when flask_styleguide is initialized. Let's write some html examples for our buttons:

    {% extends 'layout.html' %}
    {% block main %}
      {% styleguide "2.1" %}
        <button class="button$modifier_class">Button</button>
        <a class="button$modifier_class">A button link</a>
      {% endstyleguide %}
    {% endblock %}
  • The styleguide/section.html template will be used for each section in your styleguide (like 2.1 in the previous step). Let's define it:

    <article class="style-guide" id="{{ section.section }}">
      <h4 class="style-guide-reference">{{ section.section }}</h4>
    
      <div class="style-guide-description">
        <p>{{ section.description|safe }}</p>
        {% if section.modifiers %}
          <ul class="style-guide-modifiers">
            {% for m in section.modifiers %}
              <li><strong>{{ m.name }}</strong> - {{ m.description }}</li>
            {% endfor %}
          </ul>
        {% endif %}
      </div>
    
      <div class="style-guide-element">
        {{ section.example|safe }}
      </div>
    
      {% for m in section.modifiers %}
        <div class="style-guide-element">
          <small class="style-guide-modifier">{{ m.name }}</small>
          {{ m.example|safe }}
        </div>
      {% endfor %}
    
      <div class="style-guide-html">
        <pre>{{ section.example|forceescape }}</pre>
      </div>
    </article>
  • Prettify styleguide. Without styles styleguide looks not so great. Apply some styling to it or reuse this one:

    bower install --save classy-style-guide
    @import 'classy-style-guide/components.style-guide.less';
  • Now that you’re up and running. Fire up a browser and go to the brand new styleguide...

flask-styleguide-example's People

Contributors

vitalk avatar

Stargazers

 avatar

Watchers

 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.