Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate markdown-magic to auto-generate TOC and contributors #1159

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c1b944e
Use parse5 as a default parser (closes #863)
inikulin Feb 21, 2017
4abf3da
Use documents via $.load
inikulin Mar 6, 2017
ecf7210
Add test for #997
inikulin Apr 12, 2017
27ccc58
Change options format
inikulin Apr 12, 2017
ea6ccce
Update unit test
jugglinmike May 27, 2017
a816e47
1.0.0-rc.1
jugglinmike May 27, 2017
310c2cd
Improve release process
jugglinmike Jun 10, 2017
ddd036d
Correct errors in Readme.md
jugglinmike Jun 10, 2017
606adb3
Document advanced usage with htmlparser2
jugglinmike Jun 10, 2017
069be0d
Remove documentation for `xmlMode` option
jugglinmike Jun 24, 2017
d0fab44
Rename `useHtmlParser2` option
jugglinmike Jun 24, 2017
fdaf659
Update History.md (and include migration guide)
jugglinmike Jun 10, 2017
7720628
Re-write migration guide for version 1.0 (#1078)
jugglinmike Feb 20, 2018
518c93e
Pass locationInfo option to parse5 (#1155)
trevorhreed Mar 9, 2018
2e453fe
Update css-select to the latest version 🚀 (#1158)
greenkeeper[bot] Mar 9, 2018
67a9271
Use eslint & prettier, add precommit hook (#1152)
fb55 Mar 11, 2018
f7e05b5
chore(package): update mocha to version 5.0.4 (#1088)
greenkeeper[bot] Mar 11, 2018
d5b1ba1
Ensure text nodes expose the DOM level 1 API
jugglinmike Nov 1, 2014
2c7a9e1
fixing missing prop(‘outerHTML’) implementation.
Added an ‘outerHTML’…
bill-bishop Mar 11, 2018
f2c9233
Do not lint files excluded from version control (#1162)
jugglinmike Mar 11, 2018
96c0694
Correct typo in git hook configuration (#1163)
jugglinmike Mar 12, 2018
69583cc
Fix .text with a function as the argument
fb55 Mar 12, 2018
1544415
Fix `.text` being called on a collection with size > 1 with a function
fb55 Mar 12, 2018
eda3a3b
chore(package): update coveralls to version 3.0.0 (#1086)
greenkeeper[bot] Mar 15, 2018
392d7b2
Update jsdom to the latest version 🚀 (#1008)
greenkeeper[bot] Mar 15, 2018
71d7afb
Throw a useful error on invalid input to cheerio.load() (#1087)
zeke Mar 16, 2018
6ff9cb8
Merge branch 'pr/588' into v1.0.0
jugglinmike Mar 18, 2018
c95ac74
Procedurally generate API documentation from source (#1165)
jugglinmike Mar 25, 2018
f734cd4
Integrate markdown-magic to auto-generate TOC and contributors
fb55 Mar 11, 2018
727f874
Update readme
fb55 Mar 25, 2018
51b5436
Update command
fb55 Apr 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use eslint & prettier, add precommit hook (#1152)
  • Loading branch information
fb55 authored Mar 11, 2018
commit 67a9271a6461bf604f62dd3aefb673469e589388
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"node": true
},
"extends": ["eslint:recommended", "prettier"],
"globals": {},
"rules": {
"indent": [
2,
2,
{
"SwitchCase": 1,
"VariableDeclarator": 2
}
],
"no-eq-null": 0,
"no-proto": 2
}
}
11 changes: 0 additions & 11 deletions .jshintrc

This file was deleted.

6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
language: node_js
node_js:
- "stable"
- "unstable"
- "8"
- "6"
- "4"
- "0.12"
script: make travis-test
matrix:
fast_finish: true
allow_failures:
- node_js: unstable
include:
- env: BENCHMARK=true
script: "node benchmark/benchmark.js --regex '^(?!.*highmem)'"
56 changes: 23 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
Thanks for your interest in contributing to the project! Here's a rundown of
how we'd like to work with you:

1. File an issue on GitHub describing the contribution you'd like to make. This
will help us to get you started on the right foot.
2. Create a single commit that addresses the issue:
1. Follow the project's code style (see below)
2. Add enough unit tests to "prove" that your patch is correct
3. Update the project documentation as needed (see below)
4. Describe your approach with as much detail as necessary in the git
commit message
3. Open a pull request, and reference the initial issue in the pull request
message.
1. File an issue on GitHub describing the contribution you'd like to make. This
will help us to get you started on the right foot.
2. Create a single commit that addresses the issue:
1. Follow the project's code style (see below)
2. Add enough unit tests to "prove" that your patch is correct
3. Update the project documentation as needed (see below)
4. Describe your approach with as much detail as necessary in the git
commit message
3. Open a pull request, and reference the initial issue in the pull request
message.

# Documentation

Expand All @@ -22,26 +22,16 @@ care to note aspects that make Cheerio distinct.

# Code Style

This section is by no means complete. For undocumented stylistic choices,
please try to maintain consistency with the code base.

- Single quotes: `'`
- Whitespace
- Two-space "soft" tabs
- Once space following control flow statements (`if (condition) {` rather
than `if(condition) {`)
- Remove trailing spaces
- [End each file with a newline
character.](https://github.com/editorconfig/editorconfig/wiki/Newline-at-End-of-File-Support)
- Terminate every statement with a semicolon
- Private functionality (for re-using functionality that isn't part of the
jQuery API)
- *Static methods*: If the functionality does not require a reference to a
Cheerio instance, simply define a named function within the module it is
needed.
- *Instance methods*: If the functionality requires a reference to a Cheerio
instance, informally define the method as "private" using the following
conventions:
- Define the method as a function on the Cheerio prototype
- Prefix the method name with an underscore (`_`) character
- Include `@api private` in the code comment the documents the method
Please make sure commit hooks are run, which will enforce the code style.

When implementing private functionality that isn't part of the jQuery API, please opt for:

* _Static methods_: If the functionality does not require a reference to a
Cheerio instance, simply define a named function within the module it is
needed.
* _Instance methods_: If the functionality requires a reference to a Cheerio
instance, informally define the method as "private" using the following
conventions:
* Define the method as a function on the Cheerio prototype
* Prefix the method name with an underscore (`_`) character
* Include `@api private` in the code comment the documents the method
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REPORTER = dot
XYZ = node_modules/.bin/xyz --message 'Release X.Y.Z' --tag X.Y.Z --repo git@github.com:cheeriojs/cheerio.git --script scripts/prepublish

lint:
@./node_modules/.bin/jshint lib/ test/
@./node_modules/.bin/eslint .

test: lint
@./node_modules/.bin/mocha --recursive --reporter $(REPORTER)
Expand Down
5 changes: 5 additions & 0 deletions benchmark/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": 0
}
}
26 changes: 15 additions & 11 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ if (process.argv.indexOf('--cheerio-only') >= 0) {
}

suites.add('Select all', 'jquery.html', {
test: function($) { $('*').length; }
test: function($) {
$('*').length;
}
});
suites.add('Select some', 'jquery.html', {
test: function($) { $('li').length; }
test: function($) {
$('li').length;
}
});

/*
Expand Down Expand Up @@ -75,7 +79,7 @@ suites.add('manipulation - replaceWith', 'jquery.html', {
setup: function($) {
$('body').append('<div id="foo">');
},
test: function($, $lis) {
test: function($) {
$('#foo').replaceWith('<div id="foo">');
}
});
Expand Down Expand Up @@ -107,12 +111,14 @@ suites.add('manipulation - html render', 'jquery.html', {
});
suites.add('manipulation - html independent', 'jquery.html', {
setup: function() {
return '<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
+ '<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
+ '<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
+ '<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
+ '<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
+ '<div class="foo"><div id="bar">bat<hr>baz</div> </div>';
return (
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>' +
'<div class="foo"><div id="bar">bat<hr>baz</div> </div>'
);
},
test: function($, content) {
$(content).html();
Expand All @@ -128,7 +134,6 @@ suites.add('manipulation - text', 'jquery.html', {
}
});


/*
* Traversing Tests
*/
Expand Down Expand Up @@ -261,7 +266,6 @@ suites.add('traversing - Eq', 'jquery.html', {
}
});


/*
* Attributes Tests
*/
Expand Down
12 changes: 7 additions & 5 deletions benchmark/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ var jsdom = require('jsdom');
var cheerio = require('..');

var documentDir = path.join(__dirname, 'documents');
var jQuerySrc = path.join(__dirname, '../node_modules/jquery/dist/jquery.slim.js');
var jQuerySrc = path.join(
__dirname,
'../node_modules/jquery/dist/jquery.slim.js'
);
var filterRe = /./;
var cheerioOnly = false;

var Suites = module.exports = function() {};
var Suites = (module.exports = function() {});

Suites.prototype.filter = function(str) {
filterRe = new RegExp(str, 'i');
Expand All @@ -21,15 +24,14 @@ Suites.prototype.cheerioOnly = function() {
};

Suites.prototype.add = function(name, fileName, options) {
var markup, suite, testFn;
var markup, suite;
if (!filterRe.test(name)) {
return;
}
markup = fs.readFileSync(path.join(documentDir, fileName), 'utf8');
suite = new Benchmark.Suite(name);
testFn = options.test;

suite.on('start', function(event) {
suite.on('start', function() {
console.log('Test: ' + name + ' (file: ' + fileName + ')');
});
suite.on('cycle', function(event) {
Expand Down
63 changes: 30 additions & 33 deletions lib/api/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ var $ = require('../static'),
some: require('lodash/some')
},

// Lookup table for coercing string data-* attributes to their corresponding
// JavaScript primitives
primitives = {
null: null,
true: true,
false: false
},
// Lookup table for coercing string data-* attributes to their corresponding
// JavaScript primitives
primitives = {
null: null,
true: true,
false: false
},

// Attributes that are booleans
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
// Matches strings that look like JSON objects or arrays
rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/;
// Attributes that are booleans
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
// Matches strings that look like JSON objects or arrays
rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/;


var getAttr = function(elem, name) {
Expand Down Expand Up @@ -94,10 +94,10 @@ var getProp = function (el, name) {
if (!el || !isTag(el)) return;

return hasOwn.call(el, name)
? el[name]
: rboolean.test(name)
? getAttr(el, name) !== undefined
: getAttr(el, name);
? el[name]
: rboolean.test(name)
? getAttr(el, name) !== undefined
: getAttr(el, name);
};

var setProp = function (el, name, value) {
Expand Down Expand Up @@ -201,7 +201,7 @@ var readData = function(el, name) {
} else if (rbrace.test(value)) {
try {
value = JSON.parse(value);
} catch(e){ }
} catch(e){ /* ignore */ }
}

el.data[jsName] = value;
Expand Down Expand Up @@ -252,19 +252,16 @@ exports.val = function(value) {
case 'textarea':
return this.text(value);
case 'input':
switch (this.attr('type')) {
case 'radio':
if (querying) {
return this.attr('value');
} else {
this.attr('value', value);
return this;
}
break;
default:
return this.attr('value', value);
if (this.attr('type') === 'radio') {
if (querying) {
return this.attr('value');
}

this.attr('value', value);
return this;
}
return;

return this.attr('value', value);
case 'select':
var option = this.find('option:selected'),
returnValue;
Expand Down Expand Up @@ -452,11 +449,11 @@ exports.toggleClass = function(value, stateVal) {
if (!value || typeof value !== 'string') return this;

var classNames = value.split(rspace),
numClasses = classNames.length,
state = typeof stateVal === 'boolean' ? stateVal ? 1 : -1 : 0,
numElements = this.length,
elementClasses,
index;
numClasses = classNames.length,
state = typeof stateVal === 'boolean' ? stateVal ? 1 : -1 : 0,
numElements = this.length,
elementClasses,
index;

for (var i = 0; i < numElements; i++) {
// If selected element isn't a tag, move on
Expand Down
Loading