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

[docs] Keep the current version into account #11595

Merged
merged 2 commits into from
May 27, 2018

Conversation

oliviertassinari
Copy link
Member

So we don't have to push a branch for every version of the documentation we push.

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label May 26, 2018
@oliviertassinari oliviertassinari self-assigned this May 26, 2018

this.setState({ versions });
let docs = branches.map(n => n.name);
docs.sort().reverse();
Copy link
Member

Choose a reason for hiding this comment

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

The GitHub API returns the branches already sorted (regardless of the order they were added), so while harmless, sort() won't actually do anything here as I understand it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The GitHub API returns the branches already sorted

Is this by design or just by luck?

Copy link
Member

Choose a reason for hiding this comment

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

It appears to be by design - I tested it every which way, but keeping sort() can't do any harm.

this.setState({ versions });
let docs = branches.map(n => n.name);
docs.sort().reverse();
docs.pop(); // most recent first & remove 'latest'
Copy link
Member

Choose a reason for hiding this comment

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

Comment doesn't match the code.

});
docs = uniqBy(docs, 'version');
docs[0].url = 'https://material-ui.com';
this.setState({ docs });
};
Copy link
Member

Choose a reason for hiding this comment

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

Why not just add the current version to the versions array if it isn't already present (i.e if there isn't a version specific branch on GitHub)? Job done.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's what the uniq is doing without the need for a condition.

Copy link
Member

Choose a reason for hiding this comment

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

I meant instead of the entire block of code, as well as not needing the dependancy. The rest is (was) already taken care of, although I appreciate the desire to move the logic out of the render code.

Copy link
Member

Choose a reason for hiding this comment

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

let versions = [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]
> [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]

versions.unshift('v1.2.0')
> [ 'v1.2.0', 'v1.2.0', 'v1.1.0', 'v1.0.0' ]

versions =  [...new Set(versions)]
> [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]

docs.push({
version: `v${process.env.LIB_VERSION}`,
url: document.location.origin,
});
Copy link
Member

@mbrookes mbrookes May 26, 2018

Choose a reason for hiding this comment

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

docs.unshift()?

@oliviertassinari oliviertassinari merged commit 7fd6e34 into mui:master May 27, 2018
@oliviertassinari oliviertassinari deleted the docs-version-v2 branch May 27, 2018 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants