forked from moment/momentjs.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.markdown-doctest-setup.js
83 lines (67 loc) · 2.21 KB
/
.markdown-doctest-setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This file is used to configure markdown-doctest.
// It requires moment + moment-timezone and sets up all
// the implicit data used in the docs
var path = require('path');
var moment = require('moment');
var momentTimezone = require('moment-timezone');
require(path.join(__dirname, 'node_modules', 'moment-timezone', 'moment-timezone-utils'));
// Sometimes the docs deliberately call deprecated code. We don't want our
// output filled with deprecation noise.
moment.suppressDeprecationWarnings = true;
module.exports = {
ignore: ['docs/moment/10-plugins/**/*', 'libs/**/*'],
require: {
moment: moment,
'moment-timezone': momentTimezone,
'moment/locale/cs': require('moment/locale/cs')
},
beforeEach: function () {
// These examples break if we don't reset the locale before running them.
// guides/moment/00-lib-concepts/02-date-time-math.md
// guides/moment/01-parsing/05-multiple-formats.md
moment.locale('cs');
},
globals: {
moment: moment,
// mock data used to ensure examples are runnable
// docs/moment/02-get-set/19-get.md
unit: 'seconds',
// docs/moment/02-get-set/21-max.md
fetchFriends: function () {
return [
{name: 'Dan', birthday: '11.12.1977'},
{name: 'Mary', birthday: '11.12.1986'},
{name: 'Stephan', birthday: '11.01.1993'}
];
},
// docs/moment/03-manipulating/05-max.md
input: 'Jan 1 2001',
// docs/moment/04-displaying/07-difference.md
a: moment(),
b: moment().add(1, 'seconds'),
// docs/moment/06-i18n/08-locale-data.md
localeData: moment.localeData(),
aMoment: moment(),
longOrShortMonthString: 'January',
minShortOrLongWeekdayString: 'Monday',
dateFormat: 'dd-mm-yyyy',
amPmString: '12:30pm',
hours: 12,
minutes: 30,
isLower: false,
key: 'sameDay',
key: 's',
withoutSuffix: true,
isFuture: true,
number: 1,
diff: moment(),
relTime: moment.duration(1, 'seconds'),
str: 'a',
// docs/moment/08-durations/13-as.md
// docs/moment/08-durations/14-get.md
duration: moment.duration(1, 'seconds')
},
// None of the examples presently use ES6 features,
// so we can disable babel for a speedup
babel: false
}