Skip to content

Commit 614377e

Browse files
committed
add constants/docs.js, use it to ♻️ attr description links
1 parent 14133af commit 614377e

File tree

9 files changed

+45
-15
lines changed

9 files changed

+45
-15
lines changed

src/components/fx/hovertemplate_attributes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
'use strict';
1010

11+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
12+
1113
module.exports = function(opts, extra) {
1214
opts = opts || {};
1315
extra = extra || {};
@@ -37,7 +39,8 @@ module.exports = function(opts, extra) {
3739
'Note that this will override `hoverinfo`.',
3840
'Variables are inserted using %{variable}, for example "y: %{y}".',
3941
'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".',
40-
'See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax.',
42+
FORMAT_LINK,
43+
'for details on the formatting syntax.',
4144
'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data.',
4245
'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.',
4346
descPart,

src/constants/docs.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright 2012-2019, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = {
12+
FORMAT_LINK: 'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
13+
DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format'
14+
};

src/plots/cartesian/layout_attributes.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ var dash = require('../../components/drawing/attributes').dash;
1414
var extendFlat = require('../../lib/extend').extendFlat;
1515
var templatedArray = require('../../plot_api/plot_template').templatedArray;
1616

17-
var constants = require('./constants');
17+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
18+
var DATE_FORMAT_LINK = require('../../constants/docs').DATE_FORMAT_LINK;
1819

20+
var constants = require('./constants');
1921

2022
module.exports = {
2123
visible: {
@@ -554,9 +556,9 @@ module.exports = {
554556
description: [
555557
'Sets the tick label formatting rule using d3 formatting mini-languages',
556558
'which are very similar to those in Python. For numbers, see:',
557-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
559+
FORMAT_LINK,
558560
'And for dates see:',
559-
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
561+
DATE_FORMAT_LINK,
560562
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
561563
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
562564
'*%H~%M~%S.%2f* would display *09~15~23.46*'
@@ -606,9 +608,9 @@ module.exports = {
606608
description: [
607609
'Sets the hover text formatting rule using d3 formatting mini-languages',
608610
'which are very similar to those in Python. For numbers, see:',
609-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
611+
FORMAT_LINK,
610612
'And for dates see:',
611-
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
613+
DATE_FORMAT_LINK,
612614
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
613615
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
614616
'*%H~%M~%S.%2f* would display *09~15~23.46*'

src/traces/carpet/axis_attributes.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ var colorAttrs = require('../../components/color/attributes');
1313
var axesAttrs = require('../../plots/cartesian/layout_attributes');
1414
var overrideAll = require('../../plot_api/edit_types').overrideAll;
1515

16+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
17+
var DATE_FORMAT_LINK = require('../../constants/docs').TIME_FORMAT_LINK;
18+
1619
module.exports = {
1720
color: {
1821
valType: 'color',
@@ -297,9 +300,9 @@ module.exports = {
297300
description: [
298301
'Sets the tick label formatting rule using d3 formatting mini-languages',
299302
'which are very similar to those in Python. For numbers, see:',
300-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
303+
FORMAT_LINK,
301304
'And for dates see:',
302-
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
305+
DATE_FORMAT_LINK,
303306
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
304307
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
305308
'*%H~%M~%S.%2f* would display *09~15~23.46*'

src/traces/contour/attributes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ var filterOps = require('../../constants/filter_ops');
1919
var COMPARISON_OPS2 = filterOps.COMPARISON_OPS2;
2020
var INTERVAL_OPS = filterOps.INTERVAL_OPS;
2121

22+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
23+
2224
var scatterLineAttrs = scatterAttrs.line;
2325

2426
module.exports = extendFlat({
@@ -181,7 +183,7 @@ module.exports = extendFlat({
181183
description: [
182184
'Sets the contour label formatting rule using d3 formatting',
183185
'mini-language which is very similar to Python, see:',
184-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format.'
186+
FORMAT_LINK
185187
].join(' ')
186188
},
187189
operation: {

src/traces/heatmap/attributes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var scatterAttrs = require('../scatter/attributes');
1212
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
1313
var colorScaleAttrs = require('../../components/colorscale/attributes');
14+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
1415

1516
var extendFlat = require('../../lib/extend').extendFlat;
1617

@@ -113,7 +114,7 @@ module.exports = extendFlat({
113114
description: [
114115
'Sets the hover text formatting rule using d3 formatting mini-languages',
115116
'which are very similar to those in Python. See:',
116-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
117+
FORMAT_LINK
117118
].join(' ')
118119
},
119120
hovertemplate: hovertemplateAttrs()

src/traces/indicator/attributes.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var domainAttrs = require('../../plots/domain').attributes;
1717
var axesAttrs = require('../../plots/cartesian/layout_attributes');
1818
var templatedArray = require('../../plot_api/plot_template').templatedArray;
1919
var delta = require('../../constants/delta.js');
20+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
2021

2122
var textFontAttrs = fontAttrs({
2223
editType: 'plot',
@@ -168,7 +169,7 @@ module.exports = {
168169
description: [
169170
'Sets the value formatting rule using d3 formatting mini-language',
170171
'which is similar to those of Python. See',
171-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
172+
FORMAT_LINK
172173
].join(' ')
173174
},
174175
font: extendFlat({}, textFontAttrs, {
@@ -232,7 +233,7 @@ module.exports = {
232233
description: [
233234
'Sets the value formatting rule using d3 formatting mini-language',
234235
'which is similar to those of Python. See',
235-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
236+
FORMAT_LINK
236237
].join(' ')
237238
},
238239
increasing: {

src/traces/sankey/attributes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var templatedArray = require('../../plot_api/plot_template').templatedArray;
2020
var extendFlat = require('../../lib/extend').extendFlat;
2121
var overrideAll = require('../../plot_api/edit_types').overrideAll;
2222

23+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
24+
2325
var attrs = module.exports = overrideAll({
2426
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
2527
flags: [],
@@ -50,7 +52,7 @@ var attrs = module.exports = overrideAll({
5052
description: [
5153
'Sets the value formatting rule using d3 formatting mini-language',
5254
'which is similar to those of Python. See',
53-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
55+
FORMAT_LINK
5456
].join(' ')
5557
},
5658

src/traces/table/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var overrideAll = require('../../plot_api/edit_types').overrideAll;
1414
var fontAttrs = require('../../plots/font_attributes');
1515
var domainAttrs = require('../../plots/domain').attributes;
1616

17+
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
18+
1719
var attrs = module.exports = overrideAll({
1820
domain: domainAttrs({name: 'table', trace: true}),
1921

@@ -58,7 +60,7 @@ var attrs = module.exports = overrideAll({
5860
description: [
5961
'Sets the cell value formatting rule using d3 formatting mini-language',
6062
'which is similar to those of Python. See',
61-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
63+
FORMAT_LINK
6264
].join(' ')
6365
},
6466

@@ -138,7 +140,7 @@ var attrs = module.exports = overrideAll({
138140
description: [
139141
'Sets the cell value formatting rule using d3 formatting mini-language',
140142
'which is similar to those of Python. See',
141-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
143+
FORMAT_LINK
142144
].join(' ')
143145
},
144146

0 commit comments

Comments
 (0)