mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
New script for download the reference from Tom Pollard. Updated reference and readme and Makefile.
This commit is contained in:
parent
4cf1b4c1bb
commit
b33c8a093d
130
build/create_reference.pl
Normal file
130
build/create_reference.pl
Normal file
@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Grab the Arduino reference documentation from the web site and
|
||||
# modify the pages to create an offline reference.
|
||||
#
|
||||
# Author: Tom Pollard <tomp at earthlink dot net>
|
||||
# Written: Jan 12, 2008
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $verbose = 1;
|
||||
my $CURL_OPTIONS = '--silent --show-error';
|
||||
|
||||
my $ARDUINO = 'http://www.arduino.cc/en'; # base url for arduino site
|
||||
|
||||
my %downloaded = (); # keep track of the pages we download
|
||||
|
||||
my $guide = create_page('Guide_index.html', "$ARDUINO/Guide/HomePage");
|
||||
|
||||
my $faq = create_page('FAQ.html', "$ARDUINO/Main/FAQ");
|
||||
my $env = create_page('environment.html', "$ARDUINO/Main/Environment");
|
||||
my $css = create_page('arduino.css', "$ARDUINO/pub/skins/arduino/arduino.css");
|
||||
my $eeprom = create_page('EEPROM.html', "$ARDUINO/Reference/EEPROM");
|
||||
my $stepper = create_page('Stepper.html', "$ARDUINO/Reference/Stepper");
|
||||
my $softser = create_page('SoftwareSerial.html', "$ARDUINO/Reference/SoftwareSerial");
|
||||
|
||||
create_linked_pages($guide, qr!$ARDUINO/Guide/(\w+)!, 'Guide_%%.html');
|
||||
create_linked_pages($softser, qr!$ARDUINO/Reference/(SoftwareSerial\w+)!, '%%.html');
|
||||
create_linked_pages($eeprom, qr!$ARDUINO/Reference/(EEPROM\w+)!, '%%.html');
|
||||
create_linked_pages($stepper, qr!$ARDUINO/Reference/(Stepper\w+)!, '%%.html');
|
||||
|
||||
my $index = create_page('index.html', "$ARDUINO/Reference/HomePage");
|
||||
|
||||
create_linked_pages($index, qr!$ARDUINO/Serial/(\w+)!, 'Serial_%%.html');
|
||||
create_linked_pages($index, qr!$ARDUINO/Reference/(\w+)!, '%%.html');
|
||||
|
||||
my $ext = create_page('Extended.html', "$ARDUINO/Reference/Extended");
|
||||
|
||||
create_linked_pages($ext, qr!$ARDUINO/Reference/(\w+)!, '%%.html');
|
||||
|
||||
exit 0;
|
||||
|
||||
#------------------------- end of main code ----------------------------
|
||||
|
||||
########################################################################
|
||||
# $original_text = create_page($filename, $url)
|
||||
#
|
||||
# Download the web page at the given URL, change links to point to
|
||||
# the offline pages, and save it locally under the given filename.
|
||||
# The original (unmodified) text of the downloaded page is returned.
|
||||
#
|
||||
sub create_page {
|
||||
my $page = shift;
|
||||
my $url = shift;
|
||||
|
||||
print "$page\n" if $verbose;
|
||||
my $original_text = `curl $CURL_OPTIONS $url`;
|
||||
die "** Unable to download $url **\n" if $? or ! $original_text;
|
||||
$downloaded{$url} = $page; # remember that we downloaded this page
|
||||
|
||||
my $localized_text = localize_page($original_text);
|
||||
open(my $PAGE, "> $page")
|
||||
or die "** Unable to open $page for writing. **\n";
|
||||
print $PAGE $localized_text;
|
||||
close $PAGE;
|
||||
|
||||
return $original_text;
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# $localized_text = localize_page($text)
|
||||
#
|
||||
# Rewrite links in the given text to point to the offline pages.
|
||||
#
|
||||
sub localize_page {
|
||||
my $text = shift;
|
||||
|
||||
# replace links to unknown pages with links to '#'
|
||||
$text =~ s!$ARDUINO/Reference/[^?"']*\?[^'"]*!#!xg;
|
||||
|
||||
# replace links to remote guide with links to local guide
|
||||
$text =~ s!$ARDUINO/Guide/([^']+)!Guide_$1.html!xg;
|
||||
|
||||
# replace links to remote reference with links to local reference
|
||||
$text =~ s!$ARDUINO/Reference/([^']*)!$1.html!xg;
|
||||
|
||||
# replace links to remove serial reference with links to local serial reference
|
||||
$text =~ s!$ARDUINO/Serial/([^']*)!Serial_$1.html!xg;
|
||||
|
||||
# direct pages to the local style file
|
||||
$text =~ s!$ARDUINO/pub/skins/arduino/arduino.css!arduino.css!xg;
|
||||
|
||||
# change links to Main/FAQ to go to FAQ.html
|
||||
$text =~ s!$ARDUINO/Main/FAQ!FAQ.html!xg;
|
||||
|
||||
# change links to the reference HomePage to go to index.html
|
||||
$text =~ s!HomePage.html!index.html!xg;
|
||||
|
||||
# change links to the root directory to go to the Arduino home page
|
||||
$text =~ s!href="/"!href="http://www.arduino.cc"/!xg;
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# create_linked_pages($text, $link_pattern, $page_name)
|
||||
#
|
||||
# Scan the given text for links matching the $link_pattern and
|
||||
# create local files for the linked pages.
|
||||
#
|
||||
# The link_pattern is a regexp with one parenthesized subexpression -
|
||||
# the text matching the subexpression will replace the
|
||||
# special pattern '%%' in the $page_name to generate the name of
|
||||
# the local file.
|
||||
#
|
||||
sub create_linked_pages {
|
||||
my $text = shift;
|
||||
my $link_pattern = shift;
|
||||
my $new_name = shift;
|
||||
|
||||
while ($text =~ m!$link_pattern!g) {
|
||||
my ($url, $name) = ($&, $1);
|
||||
(my $page = $new_name) =~ s!%%!$name!;
|
||||
next if $name =~ /\?/ || $downloaded{$url};
|
||||
create_page($page, $url);
|
||||
}
|
||||
}
|
||||
|
||||
#---------------------------- end of code ------------------------------
|
@ -1,34 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# fetch.sh
|
||||
# David A. Mellis
|
||||
# David A. Mellis and Tom Pollard
|
||||
# Script to download reference pages from Arduino website and change links
|
||||
# to point to local copies of the pages. A terrible hack.
|
||||
# to point to local copies of the pages.
|
||||
|
||||
die () { echo ERROR: $*; exit 1; }
|
||||
|
||||
mkdir reference || die 'unable to create reference directory'
|
||||
|
||||
REVISION=`head -1 ../todo.txt | cut -c 1-4`
|
||||
mkdir reference
|
||||
cd reference
|
||||
curl http://www.arduino.cc/en/Guide/HomePage -o Guide_index.html
|
||||
curl http://www.arduino.cc/en/Main/FAQ -o FAQ.html
|
||||
curl http://arduino.cc/en/Main/Environment -o environment.html
|
||||
curl http://www.arduino.cc/en/Reference/HomePage -o index.html
|
||||
curl http://www.arduino.cc/en/Reference/SoftwareSerial -o SoftwareSerial.html
|
||||
curl http://www.arduino.cc/en/Reference/EEPROM -o EEPROM.html
|
||||
curl http://www.arduino.cc/en/Reference/Stepper -o Stepper.html
|
||||
curl http://www.arduino.cc/en/pub/skins/arduino/arduino.css -o arduino.css
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
perl -i -pe "s|http://www.arduino.cc/en/Reference/[^?\"']*\?[^'\"]*|#|g" *.html # replace links to unknown pages with links to '#'
|
||||
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
|
||||
perl -i -pe "s|http://www.arduino.cc/en/Reference/([^']*)|\1.html|g" *.html # replace links to remote reference with links to local reference
|
||||
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
|
||||
perl -i -pe "s|http://www.arduino.cc/en/pub/skins/arduino/arduino.css|arduino.css|g" *.html
|
||||
perl -i -pe "s|HomePage.html|index.html|g" *.html
|
||||
perl -i -pe "s|href=\"/\"|href=\"http://www.arduino.cc/\"|g" *.html
|
||||
perl ../create_reference.pl || die 'unable to create local reference pages'
|
||||
|
||||
cd ..
|
||||
zip -r shared/reference.zip reference
|
||||
zip -r shared/reference.zip reference || die 'unable to create reference.zip archive'
|
||||
|
||||
rm -rf reference
|
||||
|
@ -650,7 +650,6 @@
|
||||
33FFFE2C0965BD110016AC38 /* EditorListener.java */,
|
||||
33FFFE2D0965BD110016AC38 /* EditorStatus.java */,
|
||||
33FFFE2E0965BD110016AC38 /* FindReplace.java */,
|
||||
33FFFE2F0965BD110016AC38 /* language */,
|
||||
33FFFE300965BD110016AC38 /* MessageConsumer.java */,
|
||||
33FFFE310965BD110016AC38 /* MessageSiphon.java */,
|
||||
33FFFE320965BD110016AC38 /* MessageStream.java */,
|
||||
@ -678,13 +677,6 @@
|
||||
path = ../../app;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
33FFFE2F0965BD110016AC38 /* language */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = language;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33FFFE340965BD110016AC38 /* preproc */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
Binary file not shown.
@ -67,7 +67,7 @@ SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
|
||||
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp
|
||||
MCU = atmega168
|
||||
F_CPU = 16000000
|
||||
FORMAT = ihex
|
||||
|
11
readme.txt
11
readme.txt
@ -46,6 +46,17 @@ Processing and Wiring.
|
||||
|
||||
UPDATES
|
||||
|
||||
0011
|
||||
|
||||
* Fixed Find in Reference.
|
||||
* Added map() function for mapping values from one range to another.
|
||||
* Added analogReference() function.
|
||||
* Added interrupts() and noInterrupts() functions.
|
||||
* Added degrees() and radians() functions.
|
||||
* Support for uploading sketch using a programmer (upload.using preference).
|
||||
* New script for downloading the reference from Tom Pollard. Thanks Tom!
|
||||
* Miscellaneous Mac OS X and other patches from Wim Lewis. Thanks Wim!
|
||||
|
||||
0010 - 2007.10.11
|
||||
|
||||
* Support for the LilyPad Arduino.
|
||||
|
Loading…
x
Reference in New Issue
Block a user