-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Sort plot-schema and add test to track plot-schema changes #5776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
df2670d
move make_schema from tasks/util to tasks
archmoj 677e7ec
create make-schema script
archmoj 94a83dc
do not compress build/plotly.js
archmoj 76588ae
use make-schema for writing to build as well as dist
archmoj 09dfb34
rename make-schema script to schema
archmoj 818a25b
sort plot schema object before writting to file
archmoj 45f6774
commit schema file as a baseline in test folder & compate with auto-g…
archmoj 4b238c4
add a note on how to pass plot-schema diff test
archmoj 0b3ae0d
move schema diff test to publish-dist container for early failure
archmoj 74cbded
Merge remote-tracking branch 'origin/master' into plot-schema-script
archmoj a451667
Update tasks/util/sort_object.js
archmoj aea3022
sort arrays of objects in schema
archmoj 98344b6
improve handling dist argument to work with node in addition to npm
archmoj 6168306
remove alternative to test dashboard
archmoj ef99353
update CONTRIBUTING in regards with schema script
archmoj 916f1f9
Merge remote-tracking branch 'origin/master' into plot-schema-script
archmoj fcd799e
draft log for pull 5776
archmoj b29defe
Update CONTRIBUTING.md
archmoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var constants = require('./util/constants'); | ||
var plotlyNode = require('./util/plotly_node'); | ||
var sortObject = require('./util/sort_object'); | ||
|
||
function makeSchema(plotlyPath, schemaPath) { | ||
var Plotly = plotlyNode(plotlyPath); | ||
|
||
var plotSchema = sortObject(Plotly.PlotSchema.get()); | ||
var plotSchemaStr = JSON.stringify(plotSchema, null, 1); | ||
fs.writeFileSync(schemaPath, plotSchemaStr); | ||
|
||
console.log('ok ' + path.basename(schemaPath)); | ||
} | ||
|
||
var isDist = process.argv[2] === 'dist'; | ||
|
||
var pathToSchema = isDist ? | ||
constants.pathToSchemaDist : | ||
constants.pathToSchemaDiff; | ||
|
||
var pathToPlotly = isDist ? | ||
constants.pathToPlotlyDistWithMeta : | ||
constants.pathToPlotlyBuild; | ||
|
||
// output plot-schema JSON | ||
makeSchema(pathToPlotly, pathToSchema); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function caseInsensitive(a, b) { | ||
return a.toLowerCase().localeCompare(b.toLowerCase()); | ||
} | ||
|
||
function sortObject(obj) { | ||
var allKeys = Object.keys(obj); | ||
allKeys.sort(caseInsensitive); | ||
|
||
var newObj = {}; | ||
for(var i = 0; i < allKeys.length; i++) { | ||
var key = allKeys[i]; | ||
var v = obj[key]; | ||
newObj[key] = (typeof v === 'object' && v !== null && !(v instanceof Array)) ? | ||
sortObject(v) : | ||
newObj[key] = v; | ||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return newObj; | ||
} | ||
|
||
module.exports = sortObject; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we need to dig into arrays too, right? We've got stuff in the schema like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.
aea3022 also fixed cases where arrays e.g. enumerated
valType
turned into objects!Before:
After