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

Injecting examples into docs at build-time #402

Merged
merged 4 commits into from
Dec 14, 2015
Merged

Injecting examples into docs at build-time #402

merged 4 commits into from
Dec 14, 2015

Conversation

mtdowling
Copy link
Contributor

This PR adds the ability to inject examples into service documentation at doc build-time. Each service can have a file stored under boto3/examples/<service-name>.rst. If found, the contents of this file will be injected into each service's documentation output at the bottom in an "Examples" section.

@kyleknap

@mtdowling mtdowling added the pr/needs-review This PR needs a review from a member of the team. label Dec 11, 2015
@JordonPhillips
Copy link
Contributor

Could I get a screenshot of what this looks like?

@mtdowling
Copy link
Contributor Author

image

@@ -22,9 +24,12 @@


class ServiceDocumenter(object):
def __init__(self, service_name, session):
def __init__(self, service_name, session, examples_file=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Another idea is that we can make the examples directory a EXAMPLES_DIRECTORY in the class that you can override when you instantiate the class and move the _get_examples_file() to when the document_service() call is made. As this argument seems to only be needed for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update to use that approach thanks

@kyleknap
Copy link
Contributor

Looks good. Had some small comments. Another comment that I have is make sure you update the setup.py to include the examples under package_data so they get included in installation:
https://github.com/boto/boto3/blob/develop/setup.py#L43

It would be sort of simiiar to what we do for the CLI:
https://github.com/aws/aws-cli/blob/develop/setup.py#L31

@mtdowling mtdowling added incorporating-feedback and removed pr/needs-review This PR needs a review from a member of the team. labels Dec 12, 2015
@mtdowling
Copy link
Contributor Author

Feedback incorporated. I just need to add a local TOC to the examples file.

def _get_example_file(self):
return os.path.realpath(
os.sep.join([self.EXAMPLE_PATH,
self._service_name + '.rst']))
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I would prefer to use os.path.join(..., ..., ...) in favor of os.sep.join([..., ..., ...]), because it is conceptually a high level API.

This is NOT a must-fix. I will still give out a "ship-it" for this PR based on its current implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes. That's much nicer. Thanks!

@mtdowling
Copy link
Contributor Author

I've added a built-in local table of contents to the injected examples section. This relies on placing example titles as ^ subsections. Here's a screenshot.

image

@mtdowling mtdowling added pr/needs-review This PR needs a review from a member of the team. and removed incorporating-feedback labels Dec 14, 2015
@rayluo
Copy link
Contributor

rayluo commented Dec 14, 2015

🚢

@kyleknap
Copy link
Contributor

LGTM 🚢

mtdowling added a commit that referenced this pull request Dec 14, 2015
Injecting examples into docs at build-time
@mtdowling mtdowling merged commit 30e4d42 into boto:develop Dec 14, 2015
@JordonPhillips
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/needs-review This PR needs a review from a member of the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants