Skip to content
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

Ensure lack of sections does not break styleguide and update examples #119

Merged
merged 3 commits into from
Apr 11, 2016
Merged

Ensure lack of sections does not break styleguide and update examples #119

merged 3 commits into from
Apr 11, 2016

Conversation

karlbright
Copy link
Contributor

This fixes issues introduced by the merge of #108 in to master.

Both @paulj and @sapegin may have some ideas on the changes to index.js here, but this ensures that sections not being provided will not break the styleguide. There were issues with running examples as a result of this merge.

This also adds a basic example using sections for testing this new feature.

sections = []
}
components = components ? processComponents(components) : [];
sections = sections ? processSections(sections) : [];
Copy link
Member

Choose a reason for hiding this comment

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

So it will run twice?

Maybe:

if (sections) {
    sections = processSections(sections);
    components = components ? processComponents(components) : [];
}
else {
    components = processComponents(components);
    sections = sections ? processSections(sections) : [];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops. I completely forgot to take line 44 and 45 out :)

@sapegin
Copy link
Member

sapegin commented Apr 11, 2016

Please also check Travis log.

@karlbright
Copy link
Contributor Author

@sapegin The other option here is to move these to the process* functions, which means that this base code should remain quite simple?

else {
components = processComponents(components);
sections = [];
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

A trivial fix to this would be just:

components = processComponents(components);
sections = processSections(sections || []);

The intention was that you could use sections and components in parallel (if for some reason you wanted that).

Copy link
Member

Choose a reason for hiding this comment

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

That’s the best version I think.

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 wasn't clear whether they could both be provided or not, if they can then this works fine. I went for the more verbose ifelse here just to make it clear what was happening. I'd be more than happy to clean it up like this though 👍

@sapegin
Copy link
Member

sapegin commented Apr 11, 2016

But how would you check for required sections or components? (Not sure it’s necessary.)

And in you current implementation you can use only sections or components, not both. (No sure it’s critical or bad.)

@karlbright
Copy link
Contributor Author

@sapegin Yes, It wasn't clear whether or not they could both be supplied or if components were ignored when sections was provided, so I expected you or @paulj would have some information on this front.

@karlbright
Copy link
Contributor Author

So to be clear here, my understanding is this:

  • Components is not required, if the Sections property of the config is provided
  • If no Sections property is provided, then Components is expected/required to exist
  • Both Components and Sections can be provided and the styleguide takes these both in to account without issue

That last point is something I am not clear on. I assume that they can both be provided, however if a section contains a component that is provided within the components configuration property, then that component will be listed twice within the style guide. Is this correct @sapegin and @paulj?

@paulj
Copy link
Collaborator

paulj commented Apr 11, 2016

@karlbright Yes. If the same files ended up being listed twice (either in components and sections, or even just in two different sections), then they would end up being included twice.

@karlbright
Copy link
Contributor Author

@paulj Cool, figured as much. Updated to cleaner syntax, much happier.

@sapegin sapegin merged commit 3c790bf into styleguidist:master Apr 11, 2016
@sapegin
Copy link
Member

sapegin commented Apr 11, 2016

Thanks @karlbright @paulj!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants