Configuration¶
All configurations take place in your project’s conf.py file.
Note
The defaults for the extension currently support only the alabaster theme. You must provide explicit support for your Sphinx theme of choice.
Activation¶
Add sphinx_ads to the extensions list.
extensions = ["sphinx_ads",]
Create a layout.html file in the _templates/ folder under your docs/ folder. The HTML file should contain the following data:
{% extends "!layout.html" %}
{% block footer %}
{{ super() }}
{{ advertisement('layout') }}
{% endblock %}
advertisement()¶
- sphinx_ads.templates.Template.advertisement(self, layout: str = 'sphinx-ads-default') str ¶
Function to generate the advertisement HTML content you want to display in your web browser.
- Parameters:
layout – Name of the layout you want to use when presenting the advertisement content. Default layout is
sphinx-ads-default
. The value must correspond to one of the layouts in your ads JSON file or the default layout is used.- Returns:
The advertisement HTML content
Options¶
All configuration options start with the prefix ads_
for Sphinx-Ads.
ads_path¶
The ads_path
option allows you to set the path to a locally stored JSON file that contains the advertisement data.
Note
The path must be an absolute or relative path based on the conf.py directory. Example: ads_path = './ads.json'
Default: None
ads_url¶
The ads_url
option allows you to set the URL of the JSON file that contains the advertisement data.
Note
The URL must return a JSON response containing the advertisement data.
Example: ads_url = 'https://raw.githubusercontent.com/useblocks/sphinx-ads/main/docs/ads.json'
Default: None
The above options are the only options you need to set in your conf.py file.