module sphinxext.blog_post

Inheritance diagram of pyquickhelper.sphinxext.blog_post

Short summary

module pyquickhelper.sphinxext.blog_post

Helpers to process blog post included in the documentation.

source on GitHub

Classes

class

truncated documentation

BlogPost

Defines a blog post.

BlogPostParseError

Exception raised when a error comes after a blogpost was parsed.

Properties

property

truncated documentation

Author

Returns the author or None if not defined.

BlogBackground

Returns the blog background or None if not defined.

Categories

Returns the categories.

Content

Returns the content of the blogpost.

Date

Returns the date.

Fields

Returns the fields as a dictionary.

FileName

Returns the filename.

Keywords

Returns the keywords.

Tag

Produces a tag for the blog post.

Title

Returns the title.

Year

Returns the year, we assume self.date is a string like YYYY-MM-DD.

Static Methods

staticmethod

truncated documentation

build_tag

Builds the tag for a post.

Methods

method

truncated documentation

__cmp__

This method avoids to get the following error TypeError: unorderable types: BlogPost() < BlogPost().

__init__

Creates an instance of a blog post from a file or a string.

__lt__

Tells if this blog should be placed before other.

_update_link

Changes a link to an image if the page contains one into year/img.png.

post_as_rst

Reproduces the text of the blog post, updates the image links.

Documentation

Helpers to process blog post included in the documentation.

source on GitHub

class pyquickhelper.sphinxext.blog_post.BlogPost(filename, encoding='utf-8-sig', raise_exception=False, extensions=None)[source][source]

Bases: object

Defines a blog post.

source on GitHub

Creates an instance of a blog post from a file or a string.

Parameters
  • filename – filename or string

  • encoding – encoding

  • raise_exception – to raise an exception when the blog cannot be parsed

  • extensions – list of extension to use to parse the content of the blog, if None, it will consider a default list (see BlogPost and get_default_extensions())

The constructor creates the following members:

  • title

  • date

  • keywords

  • categories

  • _filename

  • _raw

  • rst_obj: the object generated by docutils (BlogPostDirective)

  • pub: Publisher

Parameter raise_exception catches the standard error.

source on GitHub

Author[source]

Returns the author or None if not defined.

source on GitHub

BlogBackground[source]

Returns the blog background or None if not defined.

source on GitHub

Categories[source]

Returns the categories.

source on GitHub

Content[source]

Returns the content of the blogpost.

source on GitHub

Date[source]

Returns the date.

source on GitHub

Fields[source]

Returns the fields as a dictionary.

source on GitHub

FileName[source]

Returns the filename.

source on GitHub

Keywords[source]

Returns the keywords.

source on GitHub

Tag[source]

Produces a tag for the blog post.

source on GitHub

Title[source]

Returns the title.

source on GitHub

Year[source]

Returns the year, we assume self.date is a string like YYYY-MM-DD.

source on GitHub

__cmp__(other)[source][source]

This method avoids to get the following error TypeError: unorderable types: BlogPost() < BlogPost().

Parameters

other – other BlogPost

Returns

-1, 0, or 1

source on GitHub

__init__(filename, encoding='utf-8-sig', raise_exception=False, extensions=None)[source][source]

Creates an instance of a blog post from a file or a string.

Parameters
  • filename – filename or string

  • encoding – encoding

  • raise_exception – to raise an exception when the blog cannot be parsed

  • extensions – list of extension to use to parse the content of the blog, if None, it will consider a default list (see BlogPost and get_default_extensions())

The constructor creates the following members:

  • title

  • date

  • keywords

  • categories

  • _filename

  • _raw

  • rst_obj: the object generated by docutils (BlogPostDirective)

  • pub: Publisher

Parameter raise_exception catches the standard error.

source on GitHub

__lt__(other)[source][source]

Tells if this blog should be placed before other.

source on GitHub

Changes a link to an image if the page contains one into year/img.png.

Parameters

row – row

Returns

new row

source on GitHub

static build_tag(date, title)[source][source]

Builds the tag for a post.

Parameters
  • date – date

  • title – title

Returns

tag or label

source on GitHub

post_as_rst(language, directive='blogpostagg', cut=False)[source][source]

Reproduces the text of the blog post, updates the image links.

Parameters
  • language – language

  • directive – to specify a different behavior based on

  • cut – truncate the post after the first paragraph

Returns

blog post as RST

New in version 1.7: Parameter cut was added.

source on GitHub

exception pyquickhelper.sphinxext.blog_post.BlogPostParseError[source][source]

Bases: Exception

Exception raised when a error comes after a blogpost was parsed.

source on GitHub