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

Generator for ECMAScript proposals templates #3

Open
chicoxyzzy opened this issue Nov 15, 2018 · 4 comments
Open

Generator for ECMAScript proposals templates #3

chicoxyzzy opened this issue Nov 15, 2018 · 4 comments

Comments

@chicoxyzzy
Copy link
Member

chicoxyzzy commented Nov 15, 2018

I'm not sure that this repo is the right place for such discussion, but it seems to be more suitable than other repositories. Sorry if this topic don't fit here. I think we can move it to another place in that case.

Contribution guide for ECMA262 proposes to document the problem but it doesn't tell how exactly. Looking at current proposal repos I noticed some common patterns on how proposal authors and champions organize files. Here is file structure for typical proposal repo:

.travis.yml
deploy.sh
package.json
README.md
spec.html

I believe that template for such project could be automatically generated. I'll split these files in 3 categories.

Proposal description

README.md file is most important. Bellow I will use [placeholder] syntax for placeholders. Possible template for this file:

# [proposal name]

[author name]
Stage: pre-proposal (?)

## Contents
1. Introduction / Description
2. Motivation / Problem
3. Examples
4. Polyfill (if exists)
5. Potential issues and open questions
6. FAQ

This could be a nice template to start describing how proposal could be useful. Contents with markdown links and placeholders with short description of sections (not shown above) can also be generated (so they are kind of similar to GitHub's issue and pull request templates)

Spec text

All proposals use ecmarkup to generate spec text. So we need two files: package.json and spec.html. Hereinafter I'll use [placeholder]s as in previous section, :hyphen-case is modifier to convert strings, for example: Proposal nameproposal-name.

package.json

{
  "private": true,
  "name": "proposal-[proposal name:hyphen-case]",
  "version": "1.0.0",
  "description": "ECMAScript [proposal name] proposal",
  "repository": "[author github name]/proposal-[proposal name:hyphen-case]",
  "author": "[author name] <[author email]>",
  "license": "SEE LICENSE IN https://tc39.github.io/ecma262/#sec-copyright-and-software-license",
  "homepage": "https://[author github name].github.io/proposal-[proposal name:hyphen-case]/",
  "dependencies": {
    "ecmarkup": "^3.12.0"
  },
  "devDependencies": {
    "@alrra/travis-scripts": "^3.0.0"
  }
}

As you can see, we reuse [proposal name] here and add three new placeholders [author github name], [author name] and [author email].

spec.html

Template for it might look so

<pre class="metadata">
title: [proposal name]
status: proposal
stage: 0
location: https://github.com/[author github name]/proposal-[proposal-name:hyphen-case]
copyright: false
contributors: [author name]
</pre>

<emu-intro id="intro">
  <h1>Introduction</h1>
  <p>TODO: add introduction text</p>
</emu-intro>

<emu-clause>
  TODO: add spec text
</emu-clause>

Now new placeholders here and again both templates are easy to autogenerate.

Deploy

To deploy proposal to gh-pages we need CI. Most of proposals in TC39 organization use Travis CI and Travis scripts have two files for deployment: deploy.sh and .travis.yaml. First one is usually the same for all repos.

Travis config file

sudo: off

language: node_js

node_js:
  - "node"

script:
  - bash ./deploy.sh

env:
  global:
    - ENCRYPTION_LABEL: TODO add encryption label here
    - GH_USER_NAME: "[author github name]"
    - GH_USER_EMAIL: "[author email]"
    - PRIVATE_KEY_FILE_NAME: "github_deploy_key.enc"

We have no new placeholders here, but we need to add some instructions to configure Travis. Good thing is that this is documented already.

Summary

We can use yeoman or other generators here. To create new proposal template one should answer these questions:

  • What is your proposal name?
  • Your GitHub nickname
  • Your full name
  • Your email
  • Do you want to generate spec template and CI configuration for deployment? (y/n)

After that proposal author fill proposal text, then do npm install, git init and push files to GitHub.
I think this will be useful for newcomers, make it easier for experienced proposal author to create new proposals and make it easier for TC39 champions for review and further editions.

There should be one convention: GitHub repo name should be proposal-[proposal name:hyphen-case]

It's also will be nice to use npx with yeoman to start template generator in one line (this feature is not implemented in yeoman though).

Does it make sense to create such generator? I'd be happy to create it and possibly also can contribute to yeoman to add npx feature (if I'll have enough free time).

@littledan
Copy link
Member

littledan commented Nov 16, 2018

This generator sounds like a great idea! One place to discuss this would be in @ljharb's https://github.com/tc39/template-for-proposals . But, this is a rather different concept from that repository, so I would encourage you to just take a stab at implementing this in a personal repository. We would probably want to accompany this all with a strong README explaining how to use it in practice, as it may not be obvious from the TODOs (especially in setting up Travis keys, and finding ecmarkup documentation).

@chicoxyzzy
Copy link
Member Author

We would probably want to accompany this all with a strong README

Sure, I meant it, just did not mention :)

@chicoxyzzy
Copy link
Member Author

chicoxyzzy commented Nov 19, 2018

note to self:

yeoman is actually an overhead, https://github.com/SBoudrias/Inquirer.js + any template engine should be enough for simple generator which can work via npx

@chicoxyzzy
Copy link
Member Author

chicoxyzzy commented Nov 23, 2018

Just finished first version of generator https://github.com/chicoxyzzy/epgen

npx epgen scaffolds very simple proposal template. I plan to write documentation next week

chicoxyzzy referenced this issue in tc39/agendas Jan 29, 2019
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

No branches or pull requests

2 participants