From 614377eed3cde85b4808cdd156d4ab0d35b135f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 12 Jul 2019 12:07:06 -0400 Subject: [PATCH 1/2] add constants/docs.js, use it to :recycle: attr description links --- src/components/fx/hovertemplate_attributes.js | 5 ++++- src/constants/docs.js | 14 ++++++++++++++ src/plots/cartesian/layout_attributes.js | 12 +++++++----- src/traces/carpet/axis_attributes.js | 7 +++++-- src/traces/contour/attributes.js | 4 +++- src/traces/heatmap/attributes.js | 3 ++- src/traces/indicator/attributes.js | 5 +++-- src/traces/sankey/attributes.js | 4 +++- src/traces/table/attributes.js | 6 ++++-- 9 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 src/constants/docs.js diff --git a/src/components/fx/hovertemplate_attributes.js b/src/components/fx/hovertemplate_attributes.js index f2111619b14..23e53961500 100644 --- a/src/components/fx/hovertemplate_attributes.js +++ b/src/components/fx/hovertemplate_attributes.js @@ -8,6 +8,8 @@ 'use strict'; +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; + module.exports = function(opts, extra) { opts = opts || {}; extra = extra || {}; @@ -37,7 +39,8 @@ module.exports = function(opts, extra) { 'Note that this will override `hoverinfo`.', 'Variables are inserted using %{variable}, for example "y: %{y}".', 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', - 'See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax.', + FORMAT_LINK, + 'for details on the formatting syntax.', 'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data.', 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', descPart, diff --git a/src/constants/docs.js b/src/constants/docs.js new file mode 100644 index 00000000000..c9c9756cc8b --- /dev/null +++ b/src/constants/docs.js @@ -0,0 +1,14 @@ +/** +* Copyright 2012-2019, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = { + FORMAT_LINK: 'https://github.com/d3/d3-format/blob/master/README.md#locale_format', + DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format' +}; diff --git a/src/plots/cartesian/layout_attributes.js b/src/plots/cartesian/layout_attributes.js index 04a44783209..41106d1686e 100644 --- a/src/plots/cartesian/layout_attributes.js +++ b/src/plots/cartesian/layout_attributes.js @@ -14,8 +14,10 @@ var dash = require('../../components/drawing/attributes').dash; var extendFlat = require('../../lib/extend').extendFlat; var templatedArray = require('../../plot_api/plot_template').templatedArray; -var constants = require('./constants'); +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; +var DATE_FORMAT_LINK = require('../../constants/docs').DATE_FORMAT_LINK; +var constants = require('./constants'); module.exports = { visible: { @@ -554,9 +556,9 @@ module.exports = { description: [ 'Sets the tick label formatting rule using d3 formatting mini-languages', 'which are very similar to those in Python. For numbers, see:', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format', + FORMAT_LINK, 'And for dates see:', - 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format', + DATE_FORMAT_LINK, 'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds', 'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat', '*%H~%M~%S.%2f* would display *09~15~23.46*' @@ -606,9 +608,9 @@ module.exports = { description: [ 'Sets the hover text formatting rule using d3 formatting mini-languages', 'which are very similar to those in Python. For numbers, see:', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format', + FORMAT_LINK, 'And for dates see:', - 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format', + DATE_FORMAT_LINK, 'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds', 'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat', '*%H~%M~%S.%2f* would display *09~15~23.46*' diff --git a/src/traces/carpet/axis_attributes.js b/src/traces/carpet/axis_attributes.js index 589c9dee56b..9d3fb672039 100644 --- a/src/traces/carpet/axis_attributes.js +++ b/src/traces/carpet/axis_attributes.js @@ -13,6 +13,9 @@ var colorAttrs = require('../../components/color/attributes'); var axesAttrs = require('../../plots/cartesian/layout_attributes'); var overrideAll = require('../../plot_api/edit_types').overrideAll; +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; +var DATE_FORMAT_LINK = require('../../constants/docs').TIME_FORMAT_LINK; + module.exports = { color: { valType: 'color', @@ -297,9 +300,9 @@ module.exports = { description: [ 'Sets the tick label formatting rule using d3 formatting mini-languages', 'which are very similar to those in Python. For numbers, see:', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format', + FORMAT_LINK, 'And for dates see:', - 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format', + DATE_FORMAT_LINK, 'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds', 'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat', '*%H~%M~%S.%2f* would display *09~15~23.46*' diff --git a/src/traces/contour/attributes.js b/src/traces/contour/attributes.js index 4d2fef35fcc..507b45d1c86 100644 --- a/src/traces/contour/attributes.js +++ b/src/traces/contour/attributes.js @@ -19,6 +19,8 @@ var filterOps = require('../../constants/filter_ops'); var COMPARISON_OPS2 = filterOps.COMPARISON_OPS2; var INTERVAL_OPS = filterOps.INTERVAL_OPS; +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; + var scatterLineAttrs = scatterAttrs.line; module.exports = extendFlat({ @@ -181,7 +183,7 @@ module.exports = extendFlat({ description: [ 'Sets the contour label formatting rule using d3 formatting', 'mini-language which is very similar to Python, see:', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format.' + FORMAT_LINK ].join(' ') }, operation: { diff --git a/src/traces/heatmap/attributes.js b/src/traces/heatmap/attributes.js index 4821fcbeb0f..1fc7aa07eb6 100644 --- a/src/traces/heatmap/attributes.js +++ b/src/traces/heatmap/attributes.js @@ -11,6 +11,7 @@ var scatterAttrs = require('../scatter/attributes'); var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes'); var colorScaleAttrs = require('../../components/colorscale/attributes'); +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; var extendFlat = require('../../lib/extend').extendFlat; @@ -113,7 +114,7 @@ module.exports = extendFlat({ description: [ 'Sets the hover text formatting rule using d3 formatting mini-languages', 'which are very similar to those in Python. See:', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, hovertemplate: hovertemplateAttrs() diff --git a/src/traces/indicator/attributes.js b/src/traces/indicator/attributes.js index 8e26eb29795..86fa7a0d6bc 100644 --- a/src/traces/indicator/attributes.js +++ b/src/traces/indicator/attributes.js @@ -17,6 +17,7 @@ var domainAttrs = require('../../plots/domain').attributes; var axesAttrs = require('../../plots/cartesian/layout_attributes'); var templatedArray = require('../../plot_api/plot_template').templatedArray; var delta = require('../../constants/delta.js'); +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; var textFontAttrs = fontAttrs({ editType: 'plot', @@ -168,7 +169,7 @@ module.exports = { description: [ 'Sets the value formatting rule using d3 formatting mini-language', 'which is similar to those of Python. See', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, font: extendFlat({}, textFontAttrs, { @@ -232,7 +233,7 @@ module.exports = { description: [ 'Sets the value formatting rule using d3 formatting mini-language', 'which is similar to those of Python. See', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, increasing: { diff --git a/src/traces/sankey/attributes.js b/src/traces/sankey/attributes.js index 57cd56072da..7fe25588f35 100644 --- a/src/traces/sankey/attributes.js +++ b/src/traces/sankey/attributes.js @@ -20,6 +20,8 @@ var templatedArray = require('../../plot_api/plot_template').templatedArray; var extendFlat = require('../../lib/extend').extendFlat; var overrideAll = require('../../plot_api/edit_types').overrideAll; +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; + var attrs = module.exports = overrideAll({ hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { flags: [], @@ -50,7 +52,7 @@ var attrs = module.exports = overrideAll({ description: [ 'Sets the value formatting rule using d3 formatting mini-language', 'which is similar to those of Python. See', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, diff --git a/src/traces/table/attributes.js b/src/traces/table/attributes.js index 6de6a04cf2f..1f918177cf1 100644 --- a/src/traces/table/attributes.js +++ b/src/traces/table/attributes.js @@ -14,6 +14,8 @@ var overrideAll = require('../../plot_api/edit_types').overrideAll; var fontAttrs = require('../../plots/font_attributes'); var domainAttrs = require('../../plots/domain').attributes; +var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK; + var attrs = module.exports = overrideAll({ domain: domainAttrs({name: 'table', trace: true}), @@ -58,7 +60,7 @@ var attrs = module.exports = overrideAll({ description: [ 'Sets the cell value formatting rule using d3 formatting mini-language', 'which is similar to those of Python. See', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, @@ -138,7 +140,7 @@ var attrs = module.exports = overrideAll({ description: [ 'Sets the cell value formatting rule using d3 formatting mini-language', 'which is similar to those of Python. See', - 'https://github.com/d3/d3-format/blob/master/README.md#locale_format' + FORMAT_LINK ].join(' ') }, From 2ec994fa8e16bda3792d8b0d0af0e5dabcfee491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 12 Jul 2019 12:10:47 -0400 Subject: [PATCH 2/2] fix #3052 - use d3@v3 api page links to *format attr descriptions --- src/constants/docs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/docs.js b/src/constants/docs.js index c9c9756cc8b..10226638f53 100644 --- a/src/constants/docs.js +++ b/src/constants/docs.js @@ -9,6 +9,6 @@ 'use strict'; module.exports = { - FORMAT_LINK: 'https://github.com/d3/d3-format/blob/master/README.md#locale_format', - DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format' + FORMAT_LINK: 'https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format', + DATE_FORMAT_LINK: 'https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format' };