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, conf=None, **kwargs_overrides)[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)

  • conf – existing configuration

  • kwargs_overrides – additional parameters for sphinx

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. Option :process: of command .. runpython:: should be used within a blog post to avoid having the same process use sphinx at the same time.

source on GitHub

property Author[source]

Returns the author or None if not defined.

source on GitHub

property BlogBackground[source]

Returns the blog background or None if not defined.

source on GitHub

property Categories[source]

Returns the categories.

source on GitHub

property Content[source]

Returns the content of the blogpost.

source on GitHub

property Date[source]

Returns the date.

source on GitHub

property Fields[source]

Returns the fields as a dictionary.

source on GitHub

property FileName[source]

Returns the filename.

source on GitHub

property Keywords[source]

Returns the keywords.

source on GitHub

property Tag[source]

Produces a tag for the blog post.

source on GitHub

property Title[source]

Returns the title.

source on GitHub

property Year[source]

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

source on GitHub

__cmp__(other)[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, conf=None, **kwargs_overrides)[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)

  • conf – existing configuration

  • kwargs_overrides – additional parameters for sphinx

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. Option :process: of command .. runpython:: should be used within a blog post to avoid having the same process use sphinx at the same time.

source on GitHub

__lt__(other)[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]

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]

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

source on GitHub

exception pyquickhelper.sphinxext.blog_post.BlogPostParseError[source]

Bases: Exception

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

source on GitHub