Skip to content

Can we use docstrings in pypyr #293

Answered by yaythomas
blaisep asked this question in Q&A
Discussion options

You must be logged in to vote

Yaml only allows single line comments with #.

Nothing stops you from declaring your own key though - just make sure it doesn't clash with a step-group name. Notice the block scalar style | indicator for multi-line strings keeping \n:

_docstring: |
  Several lines of text,
  with some "quotes" of various 'types',
  and also a blank line:

steps:
  - name: pypyr.steps.echo
     in:
       echoMe: hello

It is then up to you to parse that out of the pipeline when you generate your help docs.

import pypyr.loaders.file as pypyr_file_loader
pipe_def = pypyr_file_loader.get_pipeline_definition("pipeline_name", Path.cwd())
print(pipe_def.pipeline['_docstring'])

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by blaisep
Comment options

You must be logged in to vote
3 replies
@blaisep
Comment options

@blaisep
Comment options

@yaythomas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants