Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Allow docs to match examples from #39

Merged
merged 4 commits into from
Apr 3, 2018
Merged

Allow docs to match examples from #39

merged 4 commits into from
Apr 3, 2018

Conversation

xavdid
Copy link
Contributor

@xavdid xavdid commented Apr 3, 2018

This sort of relates to PDE-152 in that I looked at this because I was looking at that, but this it it's own thing.

Examples can now be excluded from tests. This is helpful when they conform to a functional constraint, not a schema level one. Also, made an effort to surprise devs less by putting functional restrictions into the doc.

@xavdid xavdid requested a review from eliangcs April 3, 2018 07:31
Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on this issue! I pulled and it works as expected. I have a few suggestions on the code readability. Feel free to merge once addressed. Thanks!

'Defines a field an app either needs as input, or gives as output.',
description: `Defines a field an app either needs as input, or gives as output. In addition to the requirements below, the following keys are mutually exclusive:\n\n${mutuallyExclusiveFields
.map(f => `* ${f.map(x => `\`${x}\``).join(' & ')}`)
.join('\n')}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit hard to read. Can we separate it into a function?

['dict', 'list'], // Use only one or the other
['dynamic', 'dict'], // dict is ignored
['dynamic', 'choices'] // choices are ignored
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These exclusive fields are only for FieldSchema, correct? Putting them here in constants.js is a bit confusing. Without looking at the other modules, it's not easy to tell what it is for only by the name of MUTUALLY_EXCLUSIVE_FIELDS. I suggest keeping incompatibleFields in mutuallyExclusiveFields.js and import it in FieldSchema.js. If that creates a circular import, maybe we can do the opposite, i.e., initialize incompatibleFields in FieldSchema.js and import it in mutuallyExclusiveFields.js. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, yeah. The main issue is that the checks and schemas are each expected to export a single check/schema. We can export more things, but that requires code changes wherever schemas are imported (which is a more involved change). To that end, it would make sense to have it in its own common file, which is basically constants. I'll tweak the name and add comments to make it more clear why it's there though.

{
key: 'abc',
children: [{ key: 'def', children: [{ key: 'dhi' }] }],
skip: true
Copy link
Member

@eliangcs eliangcs Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name skip looks like part of the field definition, but it's actually an internal meta field used to bypass the example tests. Can we rename so it looks more like an "internal" thing, such as _skipTest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I also moved it into a constant which will be nice as soon as it comes up a bunch of places.

@xavdid
Copy link
Contributor Author

xavdid commented Apr 3, 2018

Added comments and clarity per above in f0281f9. Thanks!

@xavdid xavdid merged commit d6b9cc7 into master Apr 3, 2018
@xavdid xavdid deleted the functional-examples branch April 3, 2018 20:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants