Skip to content

Commit d14d10e

Browse files
authored
Use dart.dev everywhere (flutter#74)
Drop section on installing from library level doc comment - it isn't useful enough there, and it had some outdated links. Replace `http://dartlang.org` with `https://dart.dev` everywhere. Add a browser example to the doc comment for `context.split` for consistency with the comment on `p.split`. Switch some doc comments to use single quotes and avoid `new`.
1 parent 2d245ec commit d14d10e

File tree

7 files changed

+198
-235
lines changed

7 files changed

+198
-235
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ underlying platform that the program is running on, you can create a
3636
[Context] and give it an explicit [Style]:
3737

3838
```dart
39-
var context = new p.Context(style: Style.windows);
39+
var context = p.Context(style: Style.windows);
4040
context.join('directory', 'file.txt');
4141
```
4242

lib/path.dart

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@
44

55
/// A comprehensive, cross-platform path manipulation library.
66
///
7-
/// ## Installing ##
8-
///
9-
/// Use [pub][] to install this package. Add the following to your
10-
/// `pubspec.yaml` file.
11-
///
12-
/// dependencies:
13-
/// path: any
14-
///
15-
/// Then run `pub install`.
16-
///
17-
/// For more information, see the [path package on pub.dartlang.org][pkg].
18-
///
19-
/// [pub]: http://pub.dartlang.org
20-
/// [pkg]: http://pub.dartlang.org/packages/path
21-
///
22-
/// ## Usage ##
23-
///
247
/// The path library was designed to be imported with a prefix, though you don't
258
/// have to if you don't want to:
269
///
@@ -30,7 +13,7 @@
3013
/// These manipulate path strings based on your current working directory and
3114
/// the path style (POSIX, Windows, or URLs) of the host platform. For example:
3215
///
33-
/// p.join("directory", "file.txt");
16+
/// p.join('directory', 'file.txt');
3417
///
3518
/// This calls the top-level [join] function to join "directory" and "file.txt"
3619
/// using the current platform's directory separator.
@@ -39,8 +22,8 @@
3922
/// underlying platform that the program is running on, you can create a
4023
/// [Context] and give it an explicit [Style]:
4124
///
42-
/// var context = new p.Context(style: Style.windows);
43-
/// context.join("directory", "file.txt");
25+
/// var context = p.Context(style: Style.windows);
26+
/// context.join('directory', 'file.txt');
4427
///
4528
/// This will join "directory" and "file.txt" using the Windows path separator,
4629
/// even when the program is run on a POSIX machine.
@@ -221,8 +204,8 @@ String extension(String path, [int level = 1]) =>
221204
///
222205
/// // URL
223206
/// p.rootPrefix('path/to/foo'); // -> ''
224-
/// p.rootPrefix('http://dartlang.org/path/to/foo');
225-
/// // -> 'http://dartlang.org'
207+
/// p.rootPrefix('https://dart.dev/path/to/foo');
208+
/// // -> 'https://dart.dev'
226209
String rootPrefix(String path) => context.rootPrefix(path);
227210

228211
/// Returns `true` if [path] is an absolute path and `false` if it is a
@@ -231,7 +214,7 @@ String rootPrefix(String path) => context.rootPrefix(path);
231214
/// On POSIX systems, absolute paths start with a `/` (forward slash). On
232215
/// Windows, an absolute path starts with `\\`, or a drive letter followed by
233216
/// `:/` or `:\`. For URLs, absolute paths either start with a protocol and
234-
/// optional hostname (e.g. `http://dartlang.org`, `file://`) or with a `/`.
217+
/// optional hostname (e.g. `https://dart.dev`, `file://`) or with a `/`.
235218
///
236219
/// URLs that start with `/` are known as "root-relative", since they're
237220
/// relative to the root of the current URL. Since root-relative paths are still
@@ -315,8 +298,8 @@ String joinAll(Iterable<String> parts) => context.joinAll(parts);
315298
/// // -> [r'\\server\share', 'foo', 'bar', 'baz']
316299
///
317300
/// // Browser
318-
/// p.split('http://dartlang.org/path/to/foo');
319-
/// // -> ['http://dartlang.org', 'path', 'to', 'foo']
301+
/// p.split('https://dart.dev/path/to/foo');
302+
/// // -> ['https://dart.dev', 'path', 'to', 'foo']
320303
List<String> split(String path) => context.split(path);
321304

322305
/// Canonicalizes [path].
@@ -367,8 +350,8 @@ String normalize(String path) => context.normalize(path);
367350
/// p.relative(r'D:\other', from: r'C:\home'); // -> 'D:\other'
368351
///
369352
/// // URL
370-
/// p.relative('http://dartlang.org', from: 'http://pub.dartlang.org');
371-
/// // -> 'http://dartlang.org'
353+
/// p.relative('https://dart.dev', from: 'https://pub.dev');
354+
/// // -> 'https://dart.dev'
372355
String relative(String path, {String from}) =>
373356
context.relative(path, from: from);
374357

@@ -422,8 +405,8 @@ String setExtension(String path, String extension) =>
422405
/// p.fromUri('file:///C:/path/to/foo') // -> r'C:\path\to\foo'
423406
///
424407
/// // URL
425-
/// p.fromUri('http://dartlang.org/path/to/foo')
426-
/// // -> 'http://dartlang.org/path/to/foo'
408+
/// p.fromUri('https://dart.dev/path/to/foo')
409+
/// // -> 'https://dart.dev/path/to/foo'
427410
///
428411
/// If [uri] is relative, a relative path will be returned.
429412
///
@@ -444,8 +427,8 @@ String fromUri(uri) => context.fromUri(uri);
444427
/// // -> Uri.parse('file:///C:/path/to/foo')
445428
///
446429
/// // URL
447-
/// p.toUri('http://dartlang.org/path/to/foo')
448-
/// // -> Uri.parse('http://dartlang.org/path/to/foo')
430+
/// p.toUri('https://dart.dev/path/to/foo')
431+
/// // -> Uri.parse('https://dart.dev/path/to/foo')
449432
///
450433
/// If [path] is relative, a relative URI will be returned.
451434
///
@@ -463,13 +446,13 @@ Uri toUri(String path) => context.toUri(path);
463446
///
464447
/// // POSIX at "/root/path"
465448
/// p.prettyUri('file:///root/path/a/b.dart'); // -> 'a/b.dart'
466-
/// p.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org'
449+
/// p.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'
467450
///
468451
/// // Windows at "C:\root\path"
469452
/// p.prettyUri('file:///C:/root/path/a/b.dart'); // -> r'a\b.dart'
470-
/// p.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org'
453+
/// p.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'
471454
///
472-
/// // URL at "http://dartlang.org/root/path"
473-
/// p.prettyUri('http://dartlang.org/root/path/a/b.dart'); // -> r'a/b.dart'
455+
/// // URL at "https://dart.dev/root/path"
456+
/// p.prettyUri('https://dart.dev/root/path/a/b.dart'); // -> r'a/b.dart'
474457
/// p.prettyUri('file:///root/path'); // -> 'file:///root/path'
475458
String prettyUri(uri) => context.prettyUri(uri);

lib/src/context.dart

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Context {
6868
/// Creates a new path by appending the given path parts to [current].
6969
/// Equivalent to [join()] with [current] as the first argument. Example:
7070
///
71-
/// var context = new Context(current: '/root');
71+
/// var context = Context(current: '/root');
7272
/// context.absolute('path', 'to', 'foo'); // -> '/root/path/to/foo'
7373
///
7474
/// If [current] isn't absolute, this won't return an absolute path.
@@ -172,8 +172,8 @@ class Context {
172172
///
173173
/// // URL
174174
/// context.rootPrefix('path/to/foo'); // -> ''
175-
/// context.rootPrefix('http://dartlang.org/path/to/foo');
176-
/// // -> 'http://dartlang.org'
175+
/// context.rootPrefix('https://dart.dev/path/to/foo');
176+
/// // -> 'https://dart.dev'
177177
String rootPrefix(String path) => path.substring(0, style.rootLength(path));
178178

179179
/// Returns `true` if [path] is an absolute path and `false` if it is a
@@ -182,7 +182,7 @@ class Context {
182182
/// On POSIX systems, absolute paths start with a `/` (forward slash). On
183183
/// Windows, an absolute path starts with `\\`, or a drive letter followed by
184184
/// `:/` or `:\`. For URLs, absolute paths either start with a protocol and
185-
/// optional hostname (e.g. `http://dartlang.org`, `file://`) or with a `/`.
185+
/// optional hostname (e.g. `https://dart.dev`, `file://`) or with a `/`.
186186
///
187187
/// URLs that start with `/` are known as "root-relative", since they're
188188
/// relative to the root of the current URL. Since root-relative paths are
@@ -315,6 +315,10 @@ class Context {
315315
/// context.split(r'C:\path\to\foo'); // -> [r'C:\', 'path', 'to', 'foo']
316316
/// context.split(r'\\server\share\path\to\foo');
317317
/// // -> [r'\\server\share', 'foo', 'bar', 'baz']
318+
///
319+
/// // Browser
320+
/// context.split('https://dart.dev/path/to/foo');
321+
/// // -> ['https://dart.dev', 'path', 'to', 'foo']
318322
List<String> split(String path) {
319323
final parsed = _parse(path);
320324
// Filter out empty parts that exist due to multiple separators in a row.
@@ -429,7 +433,7 @@ class Context {
429433
/// Attempts to convert [path] to an equivalent relative path relative to
430434
/// [current].
431435
///
432-
/// var context = new Context(current: '/root/path');
436+
/// var context = Context(current: '/root/path');
433437
/// context.relative('/root/path/a/b.dart'); // -> 'a/b.dart'
434438
/// context.relative('/root/other.dart'); // -> '../other.dart'
435439
///
@@ -451,7 +455,7 @@ class Context {
451455
/// This will also return an absolute path if an absolute [path] is passed to
452456
/// a context with a relative path for [current].
453457
///
454-
/// var context = new Context(r'some/relative/path');
458+
/// var context = Context(r'some/relative/path');
455459
/// context.relative(r'/absolute/path'); // -> '/absolute/path'
456460
///
457461
/// If [current] is relative, it may be impossible to determine a path from
@@ -986,8 +990,8 @@ class Context {
986990
/// // -> r'C:\path\to\foo'
987991
///
988992
/// // URL
989-
/// context.fromUri('http://dartlang.org/path/to/foo')
990-
/// // -> 'http://dartlang.org/path/to/foo'
993+
/// context.fromUri('https://dart.dev/path/to/foo')
994+
/// // -> 'https://dart.dev/path/to/foo'
991995
///
992996
/// If [uri] is relative, a relative path will be returned.
993997
///
@@ -1008,8 +1012,8 @@ class Context {
10081012
/// // -> Uri.parse('file:///C:/path/to/foo')
10091013
///
10101014
/// // URL
1011-
/// context.toUri('http://dartlang.org/path/to/foo')
1012-
/// // -> Uri.parse('http://dartlang.org/path/to/foo')
1015+
/// context.toUri('https://dart.dev/path/to/foo')
1016+
/// // -> Uri.parse('https://dart.dev/path/to/foo')
10131017
Uri toUri(String path) {
10141018
if (isRelative(path)) {
10151019
return style.relativePathToUri(path);
@@ -1029,18 +1033,18 @@ class Context {
10291033
/// or path-formatted.
10301034
///
10311035
/// // POSIX
1032-
/// var context = new Context(current: '/root/path');
1036+
/// var context = Context(current: '/root/path');
10331037
/// context.prettyUri('file:///root/path/a/b.dart'); // -> 'a/b.dart'
1034-
/// context.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org'
1038+
/// context.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'
10351039
///
10361040
/// // Windows
1037-
/// var context = new Context(current: r'C:\root\path');
1041+
/// var context = Context(current: r'C:\root\path');
10381042
/// context.prettyUri('file:///C:/root/path/a/b.dart'); // -> r'a\b.dart'
1039-
/// context.prettyUri('http://dartlang.org/'); // -> 'http://dartlang.org'
1043+
/// context.prettyUri('https://dart.dev/'); // -> 'https://dart.dev'
10401044
///
10411045
/// // URL
1042-
/// var context = new Context(current: 'http://dartlang.org/root/path');
1043-
/// context.prettyUri('http://dartlang.org/root/path/a/b.dart');
1046+
/// var context = Context(current: 'https://dart.dev/root/path');
1047+
/// context.prettyUri('https://dart.dev/root/path/a/b.dart');
10441048
/// // -> r'a/b.dart'
10451049
/// context.prettyUri('file:///root/path'); // -> 'file:///root/path'
10461050
String prettyUri(uri) {

lib/src/style.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class Style {
2222
/// manipulate URL paths in the browser.
2323
///
2424
/// URLs use "/" (forward slash) as separators. Absolute paths either start
25-
/// with a protocol and optional hostname (e.g. `http://dartlang.org`,
25+
/// with a protocol and optional hostname (e.g. `https://dart.dev`,
2626
/// `file://`) or with "/".
2727
static final Style url = UrlStyle();
2828

test/posix_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ void main() {
297297
test('does not walk before root on absolute paths', () {
298298
expect(context.normalize('..'), '..');
299299
expect(context.normalize('../'), '..');
300-
expect(context.normalize('http://dartlang.org/..'), 'http:');
301-
expect(context.normalize('http://dartlang.org/../../a'), 'a');
300+
expect(context.normalize('https://dart.dev/..'), 'https:');
301+
expect(context.normalize('https://dart.dev/../../a'), 'a');
302302
expect(context.normalize('file:///..'), '.');
303303
expect(context.normalize('file:///../../a'), '../a');
304304
expect(context.normalize('/..'), '/');
@@ -572,7 +572,7 @@ void main() {
572572
'/path/to/foo#bar');
573573
expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')),
574574
r'_{_}_`_^_ _"_%_');
575-
expect(() => context.fromUri(Uri.parse('http://dartlang.org')),
575+
expect(() => context.fromUri(Uri.parse('https://dart.dev')),
576576
throwsArgumentError);
577577
});
578578

@@ -604,8 +604,7 @@ void main() {
604604
});
605605

606606
test('with an http: URI', () {
607-
expect(context.prettyUri('http://dartlang.org/a/b'),
608-
'http://dartlang.org/a/b');
607+
expect(context.prettyUri('https://dart.dev/a/b'), 'https://dart.dev/a/b');
609608
});
610609

611610
test('with a relative URI', () {

0 commit comments

Comments
 (0)