Skip to content

Commit b33c8a0

Browse files
committed
New script for download the reference from Tom Pollard. Updated reference and readme and Makefile.
1 parent 4cf1b4c commit b33c8a0

File tree

6 files changed

+152
-35
lines changed

6 files changed

+152
-35
lines changed

build/create_reference.pl

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env perl
2+
#
3+
# Grab the Arduino reference documentation from the web site and
4+
# modify the pages to create an offline reference.
5+
#
6+
# Author: Tom Pollard <tomp at earthlink dot net>
7+
# Written: Jan 12, 2008
8+
#
9+
use strict;
10+
use warnings;
11+
12+
my $verbose = 1;
13+
my $CURL_OPTIONS = '--silent --show-error';
14+
15+
my $ARDUINO = 'http://www.arduino.cc/en'; # base url for arduino site
16+
17+
my %downloaded = (); # keep track of the pages we download
18+
19+
my $guide = create_page('Guide_index.html', "$ARDUINO/Guide/HomePage");
20+
21+
my $faq = create_page('FAQ.html', "$ARDUINO/Main/FAQ");
22+
my $env = create_page('environment.html', "$ARDUINO/Main/Environment");
23+
my $css = create_page('arduino.css', "$ARDUINO/pub/skins/arduino/arduino.css");
24+
my $eeprom = create_page('EEPROM.html', "$ARDUINO/Reference/EEPROM");
25+
my $stepper = create_page('Stepper.html', "$ARDUINO/Reference/Stepper");
26+
my $softser = create_page('SoftwareSerial.html', "$ARDUINO/Reference/SoftwareSerial");
27+
28+
create_linked_pages($guide, qr!$ARDUINO/Guide/(\w+)!, 'Guide_%%.html');
29+
create_linked_pages($softser, qr!$ARDUINO/Reference/(SoftwareSerial\w+)!, '%%.html');
30+
create_linked_pages($eeprom, qr!$ARDUINO/Reference/(EEPROM\w+)!, '%%.html');
31+
create_linked_pages($stepper, qr!$ARDUINO/Reference/(Stepper\w+)!, '%%.html');
32+
33+
my $index = create_page('index.html', "$ARDUINO/Reference/HomePage");
34+
35+
create_linked_pages($index, qr!$ARDUINO/Serial/(\w+)!, 'Serial_%%.html');
36+
create_linked_pages($index, qr!$ARDUINO/Reference/(\w+)!, '%%.html');
37+
38+
my $ext = create_page('Extended.html', "$ARDUINO/Reference/Extended");
39+
40+
create_linked_pages($ext, qr!$ARDUINO/Reference/(\w+)!, '%%.html');
41+
42+
exit 0;
43+
44+
#------------------------- end of main code ----------------------------
45+
46+
########################################################################
47+
# $original_text = create_page($filename, $url)
48+
#
49+
# Download the web page at the given URL, change links to point to
50+
# the offline pages, and save it locally under the given filename.
51+
# The original (unmodified) text of the downloaded page is returned.
52+
#
53+
sub create_page {
54+
my $page = shift;
55+
my $url = shift;
56+
57+
print "$page\n" if $verbose;
58+
my $original_text = `curl $CURL_OPTIONS $url`;
59+
die "** Unable to download $url **\n" if $? or ! $original_text;
60+
$downloaded{$url} = $page; # remember that we downloaded this page
61+
62+
my $localized_text = localize_page($original_text);
63+
open(my $PAGE, "> $page")
64+
or die "** Unable to open $page for writing. **\n";
65+
print $PAGE $localized_text;
66+
close $PAGE;
67+
68+
return $original_text;
69+
}
70+
71+
########################################################################
72+
# $localized_text = localize_page($text)
73+
#
74+
# Rewrite links in the given text to point to the offline pages.
75+
#
76+
sub localize_page {
77+
my $text = shift;
78+
79+
# replace links to unknown pages with links to '#'
80+
$text =~ s!$ARDUINO/Reference/[^?"']*\?[^'"]*!#!xg;
81+
82+
# replace links to remote guide with links to local guide
83+
$text =~ s!$ARDUINO/Guide/([^']+)!Guide_$1.html!xg;
84+
85+
# replace links to remote reference with links to local reference
86+
$text =~ s!$ARDUINO/Reference/([^']*)!$1.html!xg;
87+
88+
# replace links to remove serial reference with links to local serial reference
89+
$text =~ s!$ARDUINO/Serial/([^']*)!Serial_$1.html!xg;
90+
91+
# direct pages to the local style file
92+
$text =~ s!$ARDUINO/pub/skins/arduino/arduino.css!arduino.css!xg;
93+
94+
# change links to Main/FAQ to go to FAQ.html
95+
$text =~ s!$ARDUINO/Main/FAQ!FAQ.html!xg;
96+
97+
# change links to the reference HomePage to go to index.html
98+
$text =~ s!HomePage.html!index.html!xg;
99+
100+
# change links to the root directory to go to the Arduino home page
101+
$text =~ s!href="/"!href="http://www.arduino.cc"/!xg;
102+
103+
return $text;
104+
}
105+
106+
########################################################################
107+
# create_linked_pages($text, $link_pattern, $page_name)
108+
#
109+
# Scan the given text for links matching the $link_pattern and
110+
# create local files for the linked pages.
111+
#
112+
# The link_pattern is a regexp with one parenthesized subexpression -
113+
# the text matching the subexpression will replace the
114+
# special pattern '%%' in the $page_name to generate the name of
115+
# the local file.
116+
#
117+
sub create_linked_pages {
118+
my $text = shift;
119+
my $link_pattern = shift;
120+
my $new_name = shift;
121+
122+
while ($text =~ m!$link_pattern!g) {
123+
my ($url, $name) = ($&, $1);
124+
(my $page = $new_name) =~ s!%%!$name!;
125+
next if $name =~ /\?/ || $downloaded{$url};
126+
create_page($page, $url);
127+
}
128+
}
129+
130+
#---------------------------- end of code ------------------------------

build/fetch.sh

+10-26
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,18 @@
11
#!/bin/sh
22

33
# fetch.sh
4-
# David A. Mellis
4+
# David A. Mellis and Tom Pollard
55
# Script to download reference pages from Arduino website and change links
6-
# to point to local copies of the pages. A terrible hack.
6+
# to point to local copies of the pages.
7+
8+
die () { echo ERROR: $*; exit 1; }
9+
10+
mkdir reference || die 'unable to create reference directory'
711

8-
REVISION=`head -1 ../todo.txt | cut -c 1-4`
9-
mkdir reference
1012
cd reference
11-
curl http://www.arduino.cc/en/Guide/HomePage -o Guide_index.html
12-
curl http://www.arduino.cc/en/Main/FAQ -o FAQ.html
13-
curl http://arduino.cc/en/Main/Environment -o environment.html
14-
curl http://www.arduino.cc/en/Reference/HomePage -o index.html
15-
curl http://www.arduino.cc/en/Reference/SoftwareSerial -o SoftwareSerial.html
16-
curl http://www.arduino.cc/en/Reference/EEPROM -o EEPROM.html
17-
curl http://www.arduino.cc/en/Reference/Stepper -o Stepper.html
18-
curl http://www.arduino.cc/en/pub/skins/arduino/arduino.css -o arduino.css
19-
for i in `grep -o "http://www.arduino.cc/en/Guide/[^']*" Guide_index.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Guide/$i -o Guide_$i.html; done
20-
for i in `grep -o "http://www.arduino.cc/en/Reference/[^']*" index.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Reference/$i -o $i.html; done
21-
for i in `grep -o "http://www.arduino.cc/en/Serial/[^']*" index.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Serial/$i -o Serial_$i.html; done
22-
for i in `grep -o "http://www.arduino.cc/en/Reference/SoftwareSerial[^']*" SoftwareSerial.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Reference/$i -o $i.html; done
23-
for i in `grep -o "http://www.arduino.cc/en/Reference/EEPROM[^']*" EEPROM.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Reference/$i -o $i.html; done
24-
for i in `grep -o "http://www.arduino.cc/en/Reference/Stepper[^']*" Stepper.html | sort -u | grep -v '?' | cut -d '/' -f 6`; do curl http://www.arduino.cc/en/Reference/$i -o $i.html; done
25-
perl -i -pe "s|http://www.arduino.cc/en/Reference/[^?\"']*\?[^'\"]*|#|g" *.html # replace links to unknown pages with links to '#'
26-
perl -i -pe "s|http://www.arduino.cc/en/Guide/([^']*)|Guide_\1.html|g" *.html # replace links to remote guide with links to local guide
27-
perl -i -pe "s|http://www.arduino.cc/en/Reference/([^']*)|\1.html|g" *.html # replace links to remote reference with links to local reference
28-
perl -i -pe "s|http://www.arduino.cc/en/Serial/([^']*)|Serial_\1.html|g" *.html # replace links to remove serial reference with links to local serial reference
29-
perl -i -pe "s|http://www.arduino.cc/en/pub/skins/arduino/arduino.css|arduino.css|g" *.html
30-
perl -i -pe "s|HomePage.html|index.html|g" *.html
31-
perl -i -pe "s|href=\"/\"|href=\"http://www.arduino.cc/\"|g" *.html
13+
perl ../create_reference.pl || die 'unable to create local reference pages'
14+
3215
cd ..
33-
zip -r shared/reference.zip reference
16+
zip -r shared/reference.zip reference || die 'unable to create reference.zip archive'
17+
3418
rm -rf reference

build/macosx/Arduino.xcodeproj/project.pbxproj

-8
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@
650650
33FFFE2C0965BD110016AC38 /* EditorListener.java */,
651651
33FFFE2D0965BD110016AC38 /* EditorStatus.java */,
652652
33FFFE2E0965BD110016AC38 /* FindReplace.java */,
653-
33FFFE2F0965BD110016AC38 /* language */,
654653
33FFFE300965BD110016AC38 /* MessageConsumer.java */,
655654
33FFFE310965BD110016AC38 /* MessageSiphon.java */,
656655
33FFFE320965BD110016AC38 /* MessageStream.java */,
@@ -678,13 +677,6 @@
678677
path = ../../app;
679678
sourceTree = SOURCE_ROOT;
680679
};
681-
33FFFE2F0965BD110016AC38 /* language */ = {
682-
isa = PBXGroup;
683-
children = (
684-
);
685-
path = language;
686-
sourceTree = "<group>";
687-
};
688680
33FFFE340965BD110016AC38 /* preproc */ = {
689681
isa = PBXGroup;
690682
children = (

build/shared/reference.zip

35 KB
Binary file not shown.

hardware/cores/arduino/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
6767
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
6868
$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
6969
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
70-
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
70+
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp
7171
MCU = atmega168
7272
F_CPU = 16000000
7373
FORMAT = ihex

readme.txt

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ Processing and Wiring.
4646

4747
UPDATES
4848

49+
0011
50+
51+
* Fixed Find in Reference.
52+
* Added map() function for mapping values from one range to another.
53+
* Added analogReference() function.
54+
* Added interrupts() and noInterrupts() functions.
55+
* Added degrees() and radians() functions.
56+
* Support for uploading sketch using a programmer (upload.using preference).
57+
* New script for downloading the reference from Tom Pollard. Thanks Tom!
58+
* Miscellaneous Mac OS X and other patches from Wim Lewis. Thanks Wim!
59+
4960
0010 - 2007.10.11
5061

5162
* Support for the LilyPad Arduino.

0 commit comments

Comments
 (0)