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

Removed copyright notices #1765

Merged
merged 1 commit into from
Jan 13, 2019
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
9 changes: 0 additions & 9 deletions 2018-edition/convert-quotes.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#!/bin/bash
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -eu

Expand Down
19 changes: 5 additions & 14 deletions 2018-edition/nostarch.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#!/bin/bash
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -eu

Expand All @@ -16,18 +7,18 @@ cargo build --release
mkdir -p tmp
rm -rf tmp/*.md

# Get all the markdown files in the src dir,
# Get all the Markdown files in the src dir,
ls src/${1:-""}*.md | \
# except for SUMMARY.md.
# except for `SUMMARY.md`.
grep -v SUMMARY.md | \
# Extract just the filename so we can reuse it easily.
xargs -n 1 basename | \
# Remove all links followed by <!-- ignore -->, then
# Change all remaining links from markdown to italicized inline text.
# Remove all links followed by `<!-- ignore -->``, then
# Change all remaining links from Markdown to italicized inline text.
while IFS= read -r filename; do
< "src/$filename" ./target/release/remove_links \
| ./target/release/link2print \
| ./target/release/remove_markup > "tmp/$filename"
done
# Concat the files into the nostarch dir.
# Concatenate the files into the `nostarch` dir.
./target/release/concat_chapters tmp nostarch
10 changes: 0 additions & 10 deletions 2018-edition/tools/src/bin/concat_chapters.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[macro_use] extern crate lazy_static;
extern crate regex;

Expand Down
11 changes: 0 additions & 11 deletions 2018-edition/tools/src/bin/convert_quotes.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::io;
use std::io::{Read, Write};

Expand All @@ -22,7 +12,6 @@ fn main() {
}

for line in buffer.lines() {

if line.is_empty() {
is_in_inline_code = false;
}
Expand Down
15 changes: 3 additions & 12 deletions 2018-edition/tools/src/bin/lfp.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// We have some long regex literals, so:
// ignore-tidy-linelength

extern crate rustc_serialize;
extern crate docopt;
use docopt::Docopt;
extern crate rustc_serialize;
extern crate walkdir;

use docopt::Docopt;
use std::{path, fs, io};
use std::io::{BufRead, Write};

Expand Down
31 changes: 8 additions & 23 deletions 2018-edition/tools/src/bin/link2print.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// FIXME: We have some long lines that could be refactored, but it's not a big deal.
// FIXME: we have some long lines that could be refactored, but it's not a big deal.
// ignore-tidy-linelength

extern crate regex;
Expand All @@ -20,7 +9,6 @@ use std::io::{Read, Write};
use regex::{Regex, Captures};

fn main() {

write_md(parse_links(parse_references(read_md())));
}

Expand All @@ -38,7 +26,7 @@ fn write_md(output: String) {

fn parse_references(buffer: String) -> (String, HashMap<String, String>) {
let mut ref_map = HashMap::new();
// FIXME: Currently doesn't handle "title" in following line
// FIXME: currently doesn't handle "title" in following line.
let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###).unwrap();
let output = re.replace_all(&buffer, |caps: &Captures| {
let key = caps.at(1).unwrap().to_owned().to_uppercase();
Expand All @@ -52,7 +40,7 @@ fn parse_references(buffer: String) -> (String, HashMap<String, String>) {
}

fn parse_links((buffer, ref_map): (String, HashMap<String, String>)) -> String {
// FIXME: check which punctuation is allowed by spec
// FIXME: check which punctuation is allowed by spec.
let re = Regex::new(r###"(?:(?P<pre>(?:```(?:[^`]|`[^`])*`?\n```\n)|(?:[^[]`[^`\n]+[\n]?[^`\n]*`))|(?:\[(?P<name>[^]]+)\](?:(?:\([[:blank:]]*(?P<val>[^")]*[^ ])(?:[[:blank:]]*"[^"]*")?\))|(?:\[(?P<key>[^]]*)\]))?))"###).expect("could not create regex");
let error_code = Regex::new(r###"^E\d{4}$"###).expect("could not create regex");
let output = re.replace_all(&buffer, |caps: &Captures| {
Expand All @@ -62,7 +50,7 @@ fn parse_links((buffer, ref_map): (String, HashMap<String, String>)) -> String {
let name = caps.name("name").expect("could not get name").to_owned();
// Really we should ignore text inside code blocks,
// this is a hack to not try to treat `#[derive()]`,
// `[profile]`, `[test]`, or `[E\d\d\d\d]` like a link
// `[profile]`, `[test]`, or `[E\d\d\d\d]` like a link.
if name.starts_with("derive(") ||
name.starts_with("profile") ||
name.starts_with("test") ||
Expand All @@ -71,19 +59,19 @@ fn parse_links((buffer, ref_map): (String, HashMap<String, String>)) -> String {
}

let val = match caps.name("val") {
// [name](link)
// `[name](link)`
Some(value) => value.to_owned(),
None => {
match caps.name("key") {
Some(key) => {
match key {
// [name][]
// `[name][]`
"" => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
// [name][reference]
// `[name][reference]`
_ => format!("{}", ref_map.get(&key.to_uppercase()).expect(&format!("could not find url for the link text `{}`", key))),
}
}
// [name] as reference
// `[name]` as reference
None => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
}
}
Expand Down Expand Up @@ -415,7 +403,4 @@ Some text to show that the reference links can follow later.
.to_string();
assert_eq!(parse(source), target);
}



}
24 changes: 7 additions & 17 deletions 2018-edition/tools/src/bin/remove_links.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate regex;

use std::collections::HashSet;
use std::io;
use std::io::{Read, Write};
use regex::{Regex, Captures};
use std::collections::HashSet;

fn main () {
let mut buffer = String::new();
Expand All @@ -23,31 +13,31 @@ fn main () {

let mut refs = HashSet::new();

// capture all links and link references
// Capture all links and link references.
let regex = r"\[([^\]]+)\](?:(?:\[([^\]]+)\])|(?:\([^\)]+\)))(?i)<!-- ignore -->";
let link_regex = Regex::new(regex).unwrap();
let first_pass = link_regex.replace_all(&buffer, |caps: &Captures| {

// save the link reference we want to delete
// Save the link reference we want to delete.
if let Some(reference) = caps.at(2) {
refs.insert(reference.to_owned());
}

// put the link title back
// Put the link title back.
caps.at(1).unwrap().to_owned()
});

// search for the references we need to delete
// Search for the references we need to delete.
let ref_regex = Regex::new(r"\n\[([^\]]+)\]:\s.*\n").unwrap();
let out = ref_regex.replace_all(&first_pass, |caps: &Captures| {
let capture = caps.at(1).unwrap().to_owned();

// check if we've marked this reference for deletion...
// Check if we've marked this reference for deletion ...
if refs.contains(capture.as_str()) {
return "".to_string();
}

//... else we put back everything we captured
// ... else we put back everything we captured.
caps.at(0).unwrap().to_owned()
});

Expand Down
19 changes: 5 additions & 14 deletions 2018-edition/tools/src/bin/remove_markup.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate regex;

use std::io;
use std::io::{Read, Write};
use regex::{Regex, Captures};
Expand All @@ -31,23 +22,23 @@ fn write_md(output: String) {

fn remove_markup(input: String) -> String {
let filename_regex = Regex::new(r#"\A<span class="filename">(.*)</span>\z"#).unwrap();
// Captions sometimes take up multiple lines
// Captions sometimes take up multiple lines.
let caption_start_regex = Regex::new(r#"\A<span class="caption">(.*)\z"#).unwrap();
let caption_end_regex = Regex::new(r#"(.*)</span>\z"#).unwrap();
let regexen = vec![filename_regex, caption_start_regex, caption_end_regex];

let lines: Vec<_> = input.lines().flat_map(|line| {
// Remove our figure and caption markup
// Remove our figure and caption markup.
if line == "<figure>" ||
line == "<figcaption>" ||
line == "</figcaption>" ||
line == "</figure>"
{
None
// Remove our syntax highlighting and rustdoc markers
// Remove our syntax highlighting and rustdoc markers.
} else if line.starts_with("```") {
Some(String::from("```"))
// Remove the span around filenames and captions
// Remove the span around filenames and captions.
} else {
let result = regexen.iter().fold(line.to_string(), |result, regex| {
regex.replace_all(&result, |caps: &Captures| {
Expand Down
12 changes: 2 additions & 10 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
#!/bin/bash

set -e

export PATH=$PATH:/home/travis/.cargo/bin;

# feature check
# Feature check
cd ci/stable-check

cargo run -- ../../src
Expand Down
23 changes: 7 additions & 16 deletions ci/spellcheck.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#!/bin/bash
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

aspell --version

# Checks project markdown files for spell errors
# Checks project Markdown files for spelling mistakes.

# Notes:

Expand Down Expand Up @@ -45,8 +36,8 @@ dict_filename=./ci/dictionary.txt
markdown_sources=(./src/*.md)
mode="check"

# aspell repeatedly modifies personal dictionary for some purpose,
# so we should use a copy of our dictionary
# aspell repeatedly modifies the personal dictionary for some reason,
# so we should use a copy of our dictionary.
dict_path="/tmp/dictionary.txt"

if [[ "$1" == "list" ]]; then
Expand All @@ -70,7 +61,7 @@ if [[ ! -f "$dict_filename" ]]; then
echo "personal_ws-1.1 en 0 utf-8" > "$dict_filename"
cat "${markdown_sources[@]}" | aspell --ignore 3 list | sort -u >> "$dict_filename"
elif [[ "$mode" == "list" ]]; then
# List (default) mode: scan all files, report errors
# List (default) mode: scan all files, report errors.
declare -i retval=0

cp "$dict_filename" "$dict_path"
Expand All @@ -84,17 +75,17 @@ elif [[ "$mode" == "list" ]]; then
command=$(aspell --ignore 3 --personal="$dict_path" "$mode" < "$fname")
if [[ -n "$command" ]]; then
for error in $command; do
# FIXME: Find more correct way to get line number
# FIXME: find more correct way to get line number
# (ideally from aspell). Now it can make some false positives,
# because it is just a grep
# because it is just a grep.
grep --with-filename --line-number --color=always "$error" "$fname"
done
retval=1
fi
done
exit "$retval"
elif [[ "$mode" == "check" ]]; then
# Interactive mode: fix typos
# Interactive mode: fix typos.
cp "$dict_filename" "$dict_path"

if [ ! -f $dict_path ]; then
Expand Down
10 changes: 0 additions & 10 deletions ci/stable-check/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::error::Error;
use std::env;
use std::fs;
Expand Down
Loading