Merge pull request #364 from twbs/XhmikosR-patch-1

Update docs.
This commit is contained in:
XhmikosR 2016-03-15 08:38:22 +02:00
Родитель caae3b06bf 80ad44b121
Коммит d3df5801cb
2 изменённых файлов: 35 добавлений и 9 удалений

Просмотреть файл

@ -1,18 +1,22 @@
# Contributing
## Important notes
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
### Code style
The project's coding style is laid out in the JSHint, ESLint, and JSCS configurations.
### PhantomJS
Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/).
## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started with Grunt guide](http://gruntjs.com/getting-started).
First, ensure that you have the latest [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed.
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started with Grunt guide](http://gruntjs.com/getting-started).
1. Fork and clone the repo.
2. Run `npm install` to install all build dependencies (including Grunt).
@ -31,4 +35,5 @@ Assuming that you don't see any red, you're ready to go. Just be sure to run `gr
7. Push to your fork and submit a pull request.
### Licensing
By contributing your code, you agree to license your contribution under [the MIT License](https://github.com/twbs/bootlint/blob/master/LICENSE).

Просмотреть файл

@ -1,18 +1,21 @@
# Bootlint
[![NPM version](https://badge.fury.io/js/bootlint.svg)](http://badge.fury.io/js/bootlint)
[![NPM version](https://img.shields.io/npm/v/bootlint.svg)](https://www.npmjs.com/package/bootlint)
[![Build Status](https://img.shields.io/travis/twbs/bootlint/master.svg)](https://travis-ci.org/twbs/bootlint)
[![Coverage Status](https://img.shields.io/coveralls/twbs/bootlint.svg?branch=master)](https://coveralls.io/r/twbs/bootlint)
![Development Status :: 5 - Production/Stable](https://img.shields.io/badge/maturity-stable-green.svg "Development Status :: 5 - Production/Stable")
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg "MIT License")](https://github.com/twbs/bootlint/blob/master/LICENSE)
[![Dependency Status](https://david-dm.org/twbs/bootlint.svg)](https://david-dm.org/twbs/bootlint)
[![devDependency Status](https://david-dm.org/twbs/bootlint/dev-status.svg)](https://david-dm.org/twbs/bootlint#info=devDependencies)
[![Dependency Status](https://img.shields.io/david/twbs/bootlint.svg)](https://david-dm.org/twbs/bootlint)
[![devDependency Status](https://img.shields.io/david/dev/twbs/bootlint.svg)](https://david-dm.org/twbs/bootlint#info=devDependencies)
An HTML [linter](http://en.wikipedia.org/wiki/Lint_(software)) for [Bootstrap](http://getbootstrap.com) projects
An HTML [linter](https://en.wikipedia.org/wiki/Lint_%28software%29) for [Bootstrap](http://getbootstrap.com) projects
## What's Bootlint?
Bootlint is a tool that checks for several common HTML mistakes in webpages that are using [Bootstrap](http://getbootstrap.com) in a fairly "vanilla" way. Vanilla Bootstrap's components/widgets require their parts of the DOM to conform to certain structures. Bootlint checks that instances of Bootstrap components have correctly-structured HTML. Optimal usage of Bootstrap also requires that your pages include certain `<meta>` tags, an HTML5 doctype declaration, etc.; Bootlint checks that these are present.
### Caveats
Bootlint assumes that your webpage is already valid HTML5. If you need to check HTML5 validity, we recommend tools like [`vnu.jar`](https://validator.github.io/validator/), [grunt-html](https://www.npmjs.org/package/grunt-html), or [grunt-html-validation](https://www.npmjs.org/package/grunt-html-validation).
Bootlint assumes that you are using Bootstrap's default class names in your webpage, as opposed to taking advantage of the "mixins" functionality of Less or Sass to map them to custom class names. If you are using mixins, Bootlint may report some false-positive warnings. However, there are some Bootlint checks that are applicable even if you are using mixins pervasively.
@ -27,9 +30,11 @@ To use Bootlint with [Grunt](http://gruntjs.com/), use the official Grunt plugin
If you want to use Bootlint with [Gulp](http://gulpjs.com), there is an *unofficial* Gulp plugin: [gulp-bootlint](https://github.com/tschortsch/gulp-bootlint)
### On the command line
Install the module with: `npm install -g bootlint`
Run it on some HTML files:
```shell
$ bootlint /path/to/some/webpage.html another_webpage.html [...]
```
@ -37,15 +42,19 @@ $ bootlint /path/to/some/webpage.html another_webpage.html [...]
This will output the lint warnings applicable to each file.
The CLI also accepts a `--disable` (or `-d`) option to disable certain lint checks. `--disable` takes a comma-separated list of [lint problem IDs](https://github.com/twbs/bootlint/wiki). Here's an example:
```shell
$ bootlint -d W002,E020 /path/to/some/webpage.html another_webpage.html [...]
```
The CLI will also process `stdin` input which means that you can pipe into Bootlint:
```shell
$ cat mypage.html | bootlint
```
Or you could use a heredoc (mostly useful for quick testing):
```shell
$ bootlint << EOF
<button class="btn btn-default">Is this correct Bootstrap markup, Bootlint?</button>
@ -53,23 +62,29 @@ EOF
```
### In the browser
Use the following [bookmarklet](https://en.wikipedia.org/wiki/Bookmarklet) that's powered by [BootstrapCDN](https://www.bootstrapcdn.com/bootlint/):
```js
javascript:(function(){var s=document.createElement("script");s.onload=function(){bootlint.showLintReportForCurrentDocument([]);};s.src="https://maxcdn.bootstrapcdn.com/bootlint/latest/bootlint.min.js";document.body.appendChild(s)})();
```
Then check the JavaScript console for lint warning messages.
You can also manually download [the browser-ready version of Bootlint](https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js).
Bootlint is also available as a unofficial third-party web service at [bootlint.com](http://www.bootlint.com/) which lints your page simply by entering a URL, similar to the [W3C Markup Validation Service](http://validator.w3.org/). **Please note** that we do *not* operate this service and that it may use an outdated version of Bootlint. Therefore it is not the recommended way to use Bootlint.
Bootlint is also available as a unofficial third-party web service at [bootlint.com](http://www.bootlint.com/) which lints your page simply by entering a URL, similar to the [W3C Markup Validation Service](https://validator.w3.org/). **Please note** that we do *not* operate this service and that it may use an outdated version of Bootlint. Therefore it is not the recommended way to use Bootlint.
## Lint problem explanations
For detailed explanations of each lint problem, [look up the IDs](https://github.com/twbs/bootlint/wiki) (for example, [`E001`](https://github.com/twbs/bootlint/wiki/E001) or [`W002`](https://github.com/twbs/bootlint/wiki/W002)) in [our wiki](https://github.com/twbs/bootlint/wiki).
## API Documentation
Bootlint is a [CommonJS module](http://wiki.commonjs.org/wiki/Modules/1.1).
Bootlint represents the lint problems it reports using the `LintError` and `LintWarning` classes:
* `LintWarning`
* Represents a potential error. It may have false-positives.
* Constructor: `LintWarning(id, message, elements)`
@ -88,6 +103,7 @@ Bootlint represents the lint problems it reports using the `LintError` and `Lint
* (**Only available under Node.js**): When available from the underlying HTML parser (which is most of the time), the DOM elements in the collection will have a `.startLocation` property that is a `Location` (see below) indicating the location of the element in the document's HTML source
Bootlint defines the following public utility class:
* `Location` (**Only available under Node.js**)
* Represents a location in the HTML source
* Constructor: `Location(line, column)`
@ -98,6 +114,7 @@ Bootlint defines the following public utility class:
A ***reporter*** is a function that accepts exactly 1 argument of type `LintWarning` or `LintError`. Its return value is ignored. It should somehow record the problem or display it to the user.
### Browser
Bootlint exports a `bootlint` property on the global `window` object.
In a browser environment, the following public APIs are available:
@ -145,6 +162,7 @@ POST an HTML document to `/` and the document's lint problems will be returned a
The endpoint accepts an optional querystring argument named `disable`, whose value is a comma-separated list of linter IDs to disable.
Example:
```http
Request:
POST / HTTP/1.1
@ -171,12 +189,15 @@ Response:
```
## Contributing
The project's coding style is laid out in the JSHint, ESLint, and JSCS configurations. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
_Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "src" subdirectory!_
## Release History
See the [GitHub Releases page](https://github.com/twbs/bootlint/releases) for detailed changelogs.
* (next release) - `master`
* 2015-11-25 - v0.14.2: Fix critical CLI bug introduced in v0.14.0 and add tests to prevent its recurrence. Update current Bootstrap version to v3.3.6.
* 2015-11-16 - v0.14.1: Forgot to regenerate browser version when tagging v0.14.0
@ -191,10 +212,10 @@ See the [GitHub Releases page](https://github.com/twbs/bootlint/releases) for de
* 2014-11-07 - v0.8.0: When in a Node.js environment, report the locations of the HTML source code of problematic elements.
* 2014-11-01 - v0.7.0: Tweaks lint message texts. Adds 1 new lint check.
* 2014-10-31 - v0.6.0: Fixes crash bug. Adds some new lint checks. Adds HTTP API.
* 2014-10-16 - v0.5.0: Adds several new features. Add official bookmarklet. Disables auto-lint-on-load in browser. Tweaks some checks. **Not backward compatible**
* 2014-10-16 - v0.5.0: Adds several new features. Adds official bookmarklet. Disables auto-lint-on-load in browser. Tweaks some checks. **Not backward compatible**
* 2014-10-07 - v0.4.0: Adds checks for correct Glyphicon usage and correct modal DOM structure; fixes `.panel-footer` false positive
* 2014-09-26 - v0.3.0: Several bug fixes and enhancements. **Not backward compatible**
* 2014-09-23 - v0.2.0: First formal release. Announcement: http://blog.getbootstrap.com/2014/09/23/bootlint/
* 2014-09-23 - v0.2.0: First formal release. Announcement: <http://blog.getbootstrap.com/2014/09/23/bootlint/>
## License