module sphinxext.blog_post_list

Inheritance diagram of pyquickhelper.sphinxext.blog_post_list

Short summary

module pyquickhelper.sphinxext.blog_post_list

Helpers to build RST extra files inserted in the documentation.

source on GitHub

Classes

class

truncated documentation

BlogPostList

Defines a list of BlogPost.

Properties

property

truncated documentation

Lang

Returns the language.

Static Methods

staticmethod

truncated documentation

category2url

Removes accents and spaces to get a clean url.

divide_list

Divides a list into buckets of division items.

produce_aggregated_post_page

Writes the content of an aggregate page of blog posts.

write_aggregated_post_list

Writes list of posts in an aggregated manners.

Methods

method

truncated documentation

__getitem__

usual

__init__

Creates a list of BlogPost, we assume each blog post belongs to a subfolder YYYY.

__iter__

Iterates on BlogPost.

__len__

Returns the number of blog posts.

get_categories

Extracts the categories.

get_categories_group

Extracts the categories with the posts associated to it.

get_files

Extracts the files.

get_image

Returns the local path to an image in this folder.

get_keywords

Extracts the categories.

get_months

Extracts the months.

get_months_group

Extracts the months with the posts associated to it.

get_rst_links_down

Builds the rst links to months or categories to displays the bottom of the aggregated pages.

get_rst_links_up

Builds the rst links to months or categories to displays at the beginning of the aggregated pages.

write_aggregated

Writes posts in a aggregated manner (post, categories, months).

write_aggregated_categories

Writes posts in a aggregated manner per categories.

write_aggregated_chapters

Writes links to post per categories and per months.

write_aggregated_index

Writes an index.

write_aggregated_months

Writes posts in a aggregated manner per months.

write_aggregated_posts

Writes posts in a aggregated manner.

Documentation

Helpers to build RST extra files inserted in the documentation.

source on GitHub

class pyquickhelper.sphinxext.blog_post_list.BlogPostList(folder, encoding='utf8', language='en', extensions=None, fLOG=<function noLOG>)[source][source]

Bases: object

Defines a list of BlogPost.

source on GitHub

Creates a list of BlogPost, we assume each blog post belongs to a subfolder YYYY.

Parameters
  • folder – folder when to find files

  • encoding – encoding

  • language – language

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

  • fLOG – logging function

source on GitHub

property Lang[source]

Returns the language.

source on GitHub

__getitem__(key)[source][source]

usual

source on GitHub

__init__(folder, encoding='utf8', language='en', extensions=None, fLOG=<function noLOG>)[source][source]

Creates a list of BlogPost, we assume each blog post belongs to a subfolder YYYY.

Parameters
  • folder – folder when to find files

  • encoding – encoding

  • language – language

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

  • fLOG – logging function

source on GitHub

__iter__()[source][source]

Iterates on BlogPost.

source on GitHub

__len__()[source][source]

Returns the number of blog posts.

source on GitHub

static category2url(cat)[source][source]

Removes accents and spaces to get a clean url.

Parameters

cat – category name

Returns

cleaned category

source on GitHub

static divide_list(ld, division)[source][source]

Divides a list into buckets of division items.

Parameters
  • ld – list of to divide

  • division – bucket size

Returns

list fo buckets

source on GitHub

get_categories()[source][source]

Extracts the categories.

Returns

list of sorted categories

source on GitHub

get_categories_group()[source][source]

Extracts the categories with the posts associated to it.

Returns

dictionary (category, list of posts)

source on GitHub

get_files()[source][source]

Extracts the files.

Returns

list of sorted months (more recent first)

source on GitHub

get_image(img)[source][source]

Returns the local path to an image in this folder.

Parameters

img – image name (see below)

Returns

local file

Allowed image names:
  • rss: image for RSS stream

source on GitHub

get_keywords()[source][source]

Extracts the categories.

Returns

list of sorted keywords

source on GitHub

get_months()[source][source]

Extracts the months.

Returns

list of sorted months (more recent first)

source on GitHub

get_months_group()[source][source]

Extracts the months with the posts associated to it.

Returns

dictionary (months, list of posts)

source on GitHub

get_rst_links_down()[source][source]

Builds the rst links to months or categories to displays the bottom of the aggregated pages.

Returns

list of rst_links

source on GitHub

get_rst_links_up()[source][source]

Builds the rst links to months or categories to displays at the beginning of the aggregated pages.

Returns

list of rst_links

source on GitHub

static produce_aggregated_post_page(name, l, this, prev, next, main_page='Blog', rst_links_up=None, rst_links_down=None, index_terms=None, bold_title=None, language='en')[source][source]

Writes the content of an aggregate page of blog posts.

Parameters
  • name – filename to write

  • l – list of posts

  • this – reference to this page

  • prev – reference to the previous page

  • next – reference to the next page

  • main_page – name of the main page

  • rst_links_up – list of rst_links to add at the beginning of a page

  • rst_links_down – list of rst_links to add at the bottom of a page

  • index_terms – terms to index

  • bold_title – title to display of the beginning of the page

  • language – language

Returns

content of the page

source on GitHub

write_aggregated(folder, division=10, blog_title='__BLOG_TITLE__', blog_description='__BLOG_DESCRIPTION__', blog_root='__BLOG_ROOT__', only_html_index=True, only_html_agg=False)[source][source]

Writes posts in a aggregated manner (post, categories, months).

Parameters
  • folder – where to write them

  • division – add a new page every division items

  • blog_title – blog title

  • blog_description – blog description

  • blog_root – blog root (publish url)

  • only_html_index – add item .. only:: html and indent everything after the main index

  • only_html_agg – add item .. only:: html and indent everything for aggregated pages

Returns

list of produced files

Changed in version 1.7: Splits only_html into only_html_index and only_html_agg.

source on GitHub

write_aggregated_categories(folder, division=10, rst_links_up=None, rst_links_down=None, only_html=True)[source][source]

Writes posts in a aggregated manner per categories.

Parameters
  • folder – where to write them

  • division – add a new page every division items

  • rst_links_up – list of rst_links to add at the beginning of a page

  • rst_links_down – list of rst_links to add at the bottom of a page

  • only_html – add item .. only:: html and indent everything

Returns

list of produced files

source on GitHub

write_aggregated_chapters(folder)[source][source]

Writes links to post per categories and per months.

Parameters

folder – where to write them

Returns

list of produced files

source on GitHub

write_aggregated_index(folder, hidden_files=None, hidden_files_html=None, only_html=True)[source][source]

Writes an index.

Parameters
  • folder – where to write the file

  • hidden_files – creates an hidden toctree and a tocdelay_node.

  • only_html – add item .. only:: html and indent everything after the main index

  • hidden_files_html – add item .. only:: html for these pages

Returns

filename

Changed in version 1.7: Parameter hidden_files_html was added.

source on GitHub

write_aggregated_months(folder, division=10, rst_links_up=None, rst_links_down=None, only_html=True)[source][source]

Writes posts in a aggregated manner per months.

Parameters
  • folder – where to write them

  • division – add a new page every division items

  • rst_links_up – list of rst_links to add at the beginning of a page

  • rst_links_down – list of rst_links to add at the bottom of a page

  • only_html – add item .. only:: html and indent everything

Returns

list of produced files

source on GitHub

static write_aggregated_post_list(folder, lp, division, prefix, encoding, rst_links_up=None, rst_links_down=None, index_terms=None, bold_title=None, language='en', only_html=True)[source][source]

Writes list of posts in an aggregated manners.

Parameters
  • folder – when to write the aggregated posts

  • lp – list of posts

  • division – bucket size

  • prefix – prefix name for the files

  • encoding – encoding for the written files

  • rst_links_up – list of rst_links to add at the beginning of a page

  • rst_links_down – list of rst_links to add at the bottom of a page

  • index_terms – terms to index on the first bucket

  • bold_title – title to display at the beginning of the page

  • language – language

  • only_html – add item .. only:: html and indent everything

Returns

list of produced files

source on GitHub

write_aggregated_posts(folder, division=10, rst_links_up=None, rst_links_down=None, only_html=True)[source][source]

Writes posts in a aggregated manner.

Parameters
  • folder – where to write them

  • division – add a new page every division items

  • rst_links_up – list of rst_links to add at the beginning of a page

  • rst_links_down – list of rst_links to add at the bottom of a page

  • only_html – add item .. only:: html and indent everything

Returns

list of produced files

source on GitHub