Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
*-test
Makefile
/target
/doc
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,18 @@ install:
- sudo ./cargo-nightly/install.sh

script:
- cargo build --verbose
- cargo test --verbose
- cargo build
- cargo test
- rustdoc lib.rs -L target/deps

after_success: |
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
echo '<meta http-equiv=refresh content=0;url=cssparser/index.html>' > doc/index.html &&
sudo pip install ghp-import &&
ghp-import -n doc &&
git push -fq https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages

env:
- secure: TDTC2q5Trv22R1pXcMyi2mWToc201aJpCJgLlnwNzkT2bjpQj+0KQvBpI1gIoeQvSL9ud85187C0tdmR7zQmZjBt6mnNCs7EM7QDIPcUcrH0vz8v/RQ+VNxhRAeCwUP4uLEHtnvbi9Q0KXCI1cQivZuMspxVMwvajx/ylcPwb4k=

9 changes: 9 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ AR ?= ar
RUSTC ?= rustc
RUSTFLAGS ?=
EXT_DEPS ?=
RUSTDOC ?= rustdoc
RUSTDOC_FLAGS ?=
RUSTDOC_TARGET ?= doc

RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs')

Expand All @@ -28,6 +31,12 @@ check: cssparser-test
check-debug: cssparser-tests
echo -e "start\n break upcall_fail\n continue\n where\n continue" | gdb -q ./cssparser-tests

.PHONY: doc
doc: $(RUSTDOC_TARGET)/cssparser/index.html

$(RUSTDOC_TARGET)/cssparser/index.html: lib.rs $(RUST_SRC) $(EXT_DEPS)
$(RUSTDOC) $(RUSTDOC_FLAGS) $< -o $(RUSTDOC_TARGET)

.PHONY: clean
clean:
rm -f *.o *.a *.so *.dylib *.rlib *.dll *.dummy *-test
40 changes: 15 additions & 25 deletions from_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@ use parser::{parse_stylesheet_rules, StylesheetParser};

/// Determine the character encoding of a CSS stylesheet and decode it.
///
/// This is based on the presence of a :abbr:`BOM (Byte Order Mark)`,
/// an `@charset` rule,
/// and encoding meta-information.
/// This is based on the presence of a BOM (Byte Order Mark), an `@charset` rule, and
/// encoding meta-information.
///
/// :param css_bytes: A byte string.
/// :param protocol_encoding:
/// The encoding label, if any, defined by HTTP or equivalent protocol.
/// * `css_bytes`: A byte string.
/// * `protocol_encoding`: The encoding label, if any, defined by HTTP or equivalent protocol.
/// (e.g. via the `charset` parameter of the `Content-Type` header.)
/// :param environment_encoding:
/// An optional `Encoding` object
/// for the `environment encoding
/// <http://www.w3.org/TR/css-syntax/#environment-encoding>`_,
/// if any.
/// :returns:
/// A 2-tuple of a decoded Unicode string
/// and the `Encoding` object that was used.
/// * `environment_encoding`: An optional `Encoding` object for the [environment encoding]
/// (http://www.w3.org/TR/css-syntax/#environment-encoding), if any.
///
/// Returns a 2-tuple of a decoded Unicode string and the `Encoding` object that was used.
pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>)
-> (String, EncodingRef) {
Expand Down Expand Up @@ -78,18 +72,14 @@ fn decode_replace(input: &[u8], fallback_encoding: EncodingRef)-> (String, Encod

/// Parse stylesheet from bytes.
///
/// :param css_bytes: A byte string.
/// :param protocol_encoding:
/// The encoding label, if any, defined by HTTP or equivalent protocol.
/// * `css_bytes`: A byte string.
/// * `protocol_encoding`: The encoding label, if any, defined by HTTP or equivalent protocol.
/// (e.g. via the `charset` parameter of the `Content-Type` header.)
/// :param environment_encoding:
/// An optional `Encoding` object
/// for the `environment encoding
/// <http://www.w3.org/TR/css-syntax/#environment-encoding>`_,
/// if any.
/// :returns:
/// A 2-tuple of a Iterator<Result<Rule, SyntaxError>>
/// and the `Encoding` object that was used.
/// * `environment_encoding`: An optional `Encoding` object for the [environment encoding]
/// (http://www.w3.org/TR/css-syntax/#environment-encoding), if any.
///
/// Returns a 2-tuple of a `Iterator<Result<Rule, SyntaxError>>`
/// and the `Encoding` object that was used.
pub fn parse_stylesheet_rules_from_bytes(
css_bytes: &[u8], protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>)
Expand Down
8 changes: 4 additions & 4 deletions parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// http://dev.w3.org/csswg/css-syntax/#parsing

/// The input to these functions needs to implement Iterator<(ComponentValue, SourceLocation)>.
/// The input to these functions needs to implement `Iterator<(ComponentValue, SourceLocation)>`.
/// The input is consumed to avoid doing a lot of copying.
/// A conforming input can be obtained:
///
Expand All @@ -25,15 +25,15 @@ pub struct RuleListParser<T>{ iter: T }
pub struct DeclarationListParser<T>{ iter: T }

/// Parse top-level of a CSS stylesheet.
/// Return a Iterator<Result<Rule, SyntaxError>>
/// Return a `Iterator<Result<Rule, SyntaxError>>`
#[inline]
pub fn parse_stylesheet_rules<T: Iterator<Node>>(iter: T) -> StylesheetParser<T> {
StylesheetParser{ iter: iter }
}


/// Parse a non-top level list of rules eg. the content of an @media rule.
/// Return a Iterator<Result<Rule, SyntaxError>>
/// Return a `Iterator<Result<Rule, SyntaxError>>`
#[inline]
pub fn parse_rule_list<T: Iterator<Node>>(iter: T) -> RuleListParser<T> {
RuleListParser{ iter: iter }
Expand All @@ -42,7 +42,7 @@ pub fn parse_rule_list<T: Iterator<Node>>(iter: T) -> RuleListParser<T> {

/// Parse a list of declarations and at-rules,
/// like @page in CSS 2.1, all declaration lists in level 3
/// Return a Iterator<Result<DeclarationListItem, SyntaxError>>
/// Return a `Iterator<Result<DeclarationListItem, SyntaxError>>`
#[inline]
pub fn parse_declaration_list<T: Iterator<Node>>(iter: T) -> DeclarationListParser<T> {
DeclarationListParser{ iter: iter }
Expand Down
2 changes: 1 addition & 1 deletion tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::ascii::StrAsciiExt;
use ast::*;


/// Returns a Iterator<(ComponentValue, SourceLocation)>
/// Returns a `Iterator<(ComponentValue, SourceLocation)>`
pub fn tokenize(input: &str) -> Tokenizer {
let input = preprocess(input);
Tokenizer {
Expand Down