MyTetra Share
Делитесь знаниями!
customization html_theme / кастомизация темы sphinx
Время создания: 21.05.2017 10:51
Раздел: Python - sphinx
Запись: xintrea/mytetra_db_mcold/master/base/1495353116y7eu4vzbag/text.html на raw.githubusercontent.com
html_theme = "classic"
html_theme_options = {
    "rightsidebar": "true",
    "relbarbgcolor": "black"
}

That would give you the classic theme, but with a sidebar on the right side and a black background for the relation bar (the bar with the navigation links at the page’s top and bottom).

If the theme does not come with Sphinx, it can be in two static forms: either a directory (containing theme.conf and other needed files), or a zip file with the same contents. Either of them must be put where Sphinx can find it; for this there is the config value html_theme_path. It gives a list of directories, relative to the directory containing conf.py, that can contain theme directories or zip files. For example, if you have a theme in the file blue.zip, you can put it right in the directory containing conf.py and use this configuration:

html_theme = "blue"
html_theme_path = ["."]

The third form is a python package. If a theme you want to use is distributed as a python package, you can use it after installing

# installing theme package
$ pip install sphinxjp.themes.dotted

# use it in your conf.py
html_theme = "dotted"
These themes are:
  • basic – This is a basically unstyled layout used as the base for the other themes, and usable as the base for custom themes as well. The HTML contains all important elements like sidebar and relation bar. There are these options (which are inherited by the other themes):
    • nosidebar (true or false): Don’t include the sidebar. Defaults to False.
    • sidebarwidth (an integer): Width of the sidebar in pixels. (Do not include px in the value.) Defaults to 230 pixels.
  • alabaster – Alabaster theme is a modified “Kr” Sphinx theme from @kennethreitz (especially as used in his Requests project), which was itself originally based on @mitsuhiko’s theme used for Flask & related projects. You can get options information at Alabaster theme page.
  • classic – This is the classic theme, which looks like the Python 2 documentation. It can be customized via these options:
    • rightsidebar (true or false): Put the sidebar on the right side. Defaults to False.
    • stickysidebar (true or false): Make the sidebar “fixed” so that it doesn’t scroll out of view for long body content. This may not work well with all browsers. Defaults to False.
    • collapsiblesidebar (true or false): Add an experimental JavaScript snippet that makes the sidebar collapsible via a button on its side. Doesn’t work with “stickysidebar”. Defaults to False.
    • externalrefs (true or false): Display external links differently from internal links. Defaults to False.

    There are also various color and font options that can change the color scheme without having to write a custom stylesheet:

    • footerbgcolor (CSS color): Background color for the footer line.
    • footertextcolor (CSS color): Text color for the footer line.
    • sidebarbgcolor (CSS color): Background color for the sidebar.
    • sidebarbtncolor (CSS color): Background color for the sidebar collapse button (used when collapsiblesidebar is True).
    • sidebartextcolor (CSS color): Text color for the sidebar.
    • sidebarlinkcolor (CSS color): Link color for the sidebar.
    • relbarbgcolor (CSS color): Background color for the relation bar.
    • relbartextcolor (CSS color): Text color for the relation bar.
    • relbarlinkcolor (CSS color): Link color for the relation bar.
    • bgcolor (CSS color): Body background color.
    • textcolor (CSS color): Body text color.
    • linkcolor (CSS color): Body link color.
    • visitedlinkcolor (CSS color): Body color for visited links.
    • headbgcolor (CSS color): Background color for headings.
    • headtextcolor (CSS color): Text color for headings.
    • headlinkcolor (CSS color): Link color for headings.
    • codebgcolor (CSS color): Background color for code blocks.
    • codetextcolor (CSS color): Default text color for code blocks, if not set differently by the highlighting style.
    • bodyfont (CSS font-family): Font for normal text.
    • headfont (CSS font-family): Font for headings.
  • sphinxdoc – The theme used for this documentation. It features a sidebar on the right side. There are currently no options beyond nosidebar and sidebarwidth.
  • scrolls – A more lightweight theme, based on the Jinja documentation. The following color options are available:
    • headerbordercolor
    • subheadlinecolor
    • linkcolor
    • visitedlinkcolor
    • admonitioncolor
  • agogo – A theme created by Andi Albrecht. The following options are supported:
    • bodyfont (CSS font family): Font for normal text.
    • headerfont (CSS font family): Font for headings.
    • pagewidth (CSS length): Width of the page content, default 70em.
    • documentwidth (CSS length): Width of the document (without sidebar), default 50em.
    • sidebarwidth (CSS length): Width of the sidebar, default 20em.
    • bgcolor (CSS color): Background color.
    • headerbg (CSS value for “background”): background for the header area, default a grayish gradient.
    • footerbg (CSS value for “background”): background for the footer area, default a light gray gradient.
    • linkcolor (CSS color): Body link color.
    • headercolor1headercolor2 (CSS color): colors for <h1> and <h2> headings.
    • headerlinkcolor (CSS color): Color for the backreference link in headings.
    • textalign (CSS text-align value): Text alignment for the body, default is justify.
  • nature – A greenish theme. There are currently no options beyond nosidebar and sidebarwidth.
  • pyramid – A theme from the Pyramid web framework project, designed by Blaise Laflamme. There are currently no options beyond nosidebar and sidebarwidth.
  • haiku – A theme without sidebar inspired by the Haiku OS user guide. The following options are supported:
    • full_logo (true or false, default False): If this is true, the header will only show the html_logo. Use this for large logos. If this is false, the logo (if present) will be shown floating right, and the documentation title will be put in the header.
    • textcolorheadingcolorlinkcolorvisitedlinkcolorhoverlinkcolor (CSS colors): Colors for various body elements.
  • traditional – A theme resembling the old Python documentation. There are currently no options beyond nosidebar and sidebarwidth.
  • epub – A theme for the epub builder. This theme tries to save visual space which is a sparse resource on ebook readers. The following options are supported:
  • relbar1 (true or false, default True): If this is true, the relbar1 block is inserted in the epub output, otherwise it is omitted.
  • footer (true or false, default True): If this is true, the footer block is inserted in the epub output, otherwise it is omitted.
  • bizstyle – A simple bluish theme. The following options are supported beyond nosidebar and sidebarwidth:
  • rightsidebar (true or false): Put the sidebar on the right side. Defaults to False.
 
MyTetra Share v.0.59
Яндекс индекс цитирования