def get_rst_excerpt(rst_doc: document, paragraphs: int = 1) -> str:
    """ Given rst, parse and return a portion """

    texts = []
    for count, p in enumerate(rst_doc.traverse(paragraph)):
        texts.append(p.astext())
        if count + 1 == paragraphs:
            break
    return ' '.join(texts)
def get_rst_excerpt ( rst_doc : document , paragraphs : int = 1 ) -> str : texts = [ ] for count , p in enumerate ( rst_doc . traverse ( paragraph ) ) : texts . append ( p . astext ( ) ) if count + 1 == paragraphs : break return ' ' . join ( texts )
Given rst, parse and return a portion