-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add basic readme generator #580
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
Conversation
/cc @jmdobry |
|
Nah, at least not for now. The templates and generator are pretty python-specific right now. DPEbot could handle running
Many Python projects use rst and github supports both (yay). I personally prefer rst. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine, technically (though you might want to add tests, if we're going to be using this extensively).
I'm concerned that this is overengineering the problem, though. eg what are the pros and cons of this approach, vs having a template directory that you can copy and modify when you create a new sample?
My take:
- Pro: common templates for auth, setup - easier management for commonly-repeated instructions
- Con: Another management system to learn and maintain
It sort of feels like this is a tool to make github READMEs into a CMS...
@@ -320,3 +320,12 @@ def mark_if_necessary(requirement): | |||
for requirement in sorted(requirements, key=lambda s: s.lower()): | |||
if not requirement.startswith('#'): | |||
f.write(requirement) | |||
|
|||
|
|||
def session_readmegen(session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...read-memegen
😏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
def session_readmegen(session): | ||
session.install('-r', 'testing/requirements-dev.txt') | ||
|
||
in_files = list(list_files('.', 'README.rst.in')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a .yaml extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.in
indicates that the file is used to generate the file of the same name before it, so README.rst.in
-> README.rst
, whereas README.yaml.in
-> README.yaml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - I meant README.rst.yaml
to make clear that it's a yaml file (and for syntax highlighting, etc). The fact that it's an input to the resulting rst
would be implied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .in
is clearer that it's used exclusively for generating the README.rst
file, but I'm happy to be disagreed with. @waprin, thoughts?
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A module-level docstring would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a simple one for now.
@@ -0,0 +1,63 @@ | |||
#!/usr/bin/env python | |||
|
|||
# Copyright (C) 2013 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
loader=jinja2.FileSystemLoader( | ||
os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) | ||
|
||
README_TMPL = jinja_env.get_template('README.tmpl.rst') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: we could adopt the rails convention of ordering the file extensions by processing order? ie README.rst.jinja2, where it'd get processed by jinja2 first, then as an rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh.
@@ -0,0 +1,60 @@ | |||
.. This file is automatically generated. Do not edit this file directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly add a jinja2 comment that's like:
{# The following line is a lie. BUT! Once jinja2 is done with it, it will become truth! #}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (verbatim)
nox --stop-on-first-error -s lint travis; | ||
source ${TRAVIS_BUILD_DIR}/testing/test-env.sh; | ||
export GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/service-account.json | ||
nox --stop-on-first-error -s lint travis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a purist if you want to sneak this in there, but it does look like this should be a separate PR? Or is this somehow related and I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I need to rebase. Just consider this part of the diffbase.
Overall very nice idea, writing the README is a pain and good to standardize on our texts etc. Might be helpful to add a quick usage doc on using the README generator? |
Change-Id: I53b753fb7e422161b443cd6d96df9501a7b37ab4
The pros of this approach is knowing that everything is always consistent. The cons of course are that it is a bit over-engineered and might be hard to maintain down the road, and it might be difficult to accommodate special situations (like speech's portaudio dependency). If we just have a template directory we will inevitably forget to update READMEs after their initial creation. I could also go the other direction, like we did with auto-docs-links. Instead of this generating READMEs, it could just fill in sections of READMEs automatically: README.rst
Then when you run the generator/filler:
Let me get it working across several more samples and then I'll add a README.rst to the README generator. ;) |
@pfritzsche should readme-gen generate its own readme and read memegen at once? |
Change-Id: I67bd8a38f39feb78c669c4e5b25e0293094c10be
b81b3ae
to
49b0318
Compare
++++++++++++++ | ||
|
||
Authentication is typically done through `Application Default Credentials`_, | ||
this means you do not have to change the code to authenticate as long as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentence fragment. Consider:
Authentication is typically done through
Application Default Credentials
, which...
instead of "this"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*shrug
Have at it!
def session_readmegen(session): | ||
session.install('-r', 'testing/requirements-dev.txt') | ||
|
||
in_files = list(list_files('.', 'README.rst.in')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - I meant README.rst.yaml
to make clear that it's a yaml file (and for syntax highlighting, etc). The fact that it's an input to the resulting rst
would be implied.
Change-Id: Ie33893bd2a1f36a34ab7dbb14c01425c9d0eebb5
@waprin ping? |
|
||
.. code-block:: bash | ||
|
||
gcloud beta auth application-default login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think the command is out of beta
samples: | ||
- name: Snippets | ||
file: snippets.py | ||
show_help: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe show_help defaults to true?
LGTM |
(Only used for storage, but once in I'll start adding other products)