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

use handlebars for code generation #2228

Merged
merged 12 commits into from
May 4, 2020
Merged

Conversation

xlc
Copy link
Contributor

@xlc xlc commented May 3, 2020

Convert typegen code to use handlebars syntax.

The result is almost identical except for empty lines are preserved in doc comments.

fromChain is not updated as I can't find an easy way to run docs/examples/promise/90_typegen to compare output. Can do it in later PR.

@xlc xlc marked this pull request as draft May 3, 2020 10:20
@xlc xlc force-pushed the refactor-typegen branch from 29a271a to 43b988c Compare May 3, 2020 10:28
@jacogr
Copy link
Member

jacogr commented May 3, 2020

Thanks for this. It is def an avenue worth exploring. Most probably will not get to having an proper look today (don't want to skimp over it and want to do it properly)

Copy link
Member

@jacogr jacogr left a comment

Choose a reason for hiding this comment

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

I agree with your initial assessment that the templates may be a bit tougher (although editors should have .hbs helpers, obv. being non-HTML is not perfect), however it does remove a lot of absolutely horrible code that is also duplicated in each generator.

I do think this is an overall win, even if the remaining code is still not stunningly pretty.

@xlc xlc marked this pull request as ready for review May 4, 2020 10:16
Copy link
Member

@jacogr jacogr left a comment

Choose a reason for hiding this comment

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

lgtm.

(In this case the generated output being added makes a lot of sense, can see they match 100%... well, apart from the comments being much nicer now)

@@ -51,6 +51,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
*
Copy link
Member

Choose a reason for hiding this comment

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

Def much better, also in the editor. Thank you.

@jacogr jacogr merged commit 174510a into polkadot-js:master May 4, 2020
@xlc xlc deleted the refactor-typegen branch May 4, 2020 21:24
@jacogr jacogr mentioned this pull request May 6, 2020
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 6, 2021
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.

3 participants