From 234e606b41a021e11d60d9494ff579ca6d0054c6 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Mon, 3 Apr 2023 01:37:26 +0200
Subject: [PATCH] doc: Replace custom domain with add_object_type
Less overhead and doesn't require a new dependency
---
doc/conf.py | 37 +++++++++++++++++++++++++-----
doc/configdomain.py | 48 ---------------------------------------
doc/requirements.txt | 1 -
doc/user/modules/tray.rst | 12 +++++-----
4 files changed, 37 insertions(+), 61 deletions(-)
delete mode 100644 doc/configdomain.py
delete mode 100644 doc/requirements.txt
diff --git a/doc/conf.py b/doc/conf.py
index df345396..f4b088e7 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -13,12 +13,14 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
-import sys
from pathlib import Path
import datetime
import sphinx
import packaging.version
+from sphinx.util.docfields import Field
+from sphinx.locale import _
+
def get_version(root_path):
"""
@@ -113,8 +115,6 @@ highlight_language = 'none'
smartquotes = False
-primary_domain = 'polybar'
-
# -- Options for HTML output -------------------------------------------------
@@ -240,9 +240,34 @@ suppress_warnings = ['app.add_directive']
def setup(app):
- sys.path.insert(0, os.path.abspath(doc_path))
- from configdomain import myDomain
- app.add_domain(myDomain)
+ app.add_object_type(
+ 'poly-setting',
+ 'poly-setting',
+ objname='configuration value',
+ indextemplate='pair: %s; configuration value',
+ doc_field_types=[
+ Field('type',
+ label=_("Type"),
+ names=['type'],
+ has_arg=False,
+ ),
+ Field('tags',
+ label=_("Available Tags"),
+ names=['tags'],
+ has_arg=False,
+ ),
+ Field('tokens',
+ label=_("Supported Tokens"),
+ names=['tokens'],
+ has_arg=False,
+ ),
+ Field('default',
+ label=_("Default Value"),
+ names=['default'],
+ has_arg=False,
+ ),
+ ]
+ )
try:
inject_version_directives(app)
diff --git a/doc/configdomain.py b/doc/configdomain.py
deleted file mode 100644
index 194209c1..00000000
--- a/doc/configdomain.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- configdomain
- ~~~~~~~~~~~~
-
- TODO document
-"""
-
-from sphinxcontrib.domaintools import custom_domain
-from sphinx.util.docfields import Field, GroupedField
-
-__version__ = "0.1.0"
-# for this module's sphinx doc
-release = __version__
-version = release.rsplit('.', 1)[0]
-
-
-myDomain = custom_domain('PolybarConfigDomain',
- name='polybar',
- label="Polybar Configuration",
-
- elements=dict(
- setting=dict(
- objname="Config Setting",
- fields=[
- Field('type',
- label="Type",
- names=['type'],
- has_arg=False,
- ),
- Field('tags',
- label="Available Tags",
- names=['tags'],
- has_arg=False,
- ),
- Field('tokens',
- label="Supported Tokens",
- names=['tokens'],
- has_arg=False,
- ),
- Field('default',
- label="Default Value",
- names=['default'],
- has_arg=False,
- ),
- ]
- ),
- ))
diff --git a/doc/requirements.txt b/doc/requirements.txt
deleted file mode 100644
index 186aa267..00000000
--- a/doc/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-sphinxcontrib-domaintools
diff --git a/doc/user/modules/tray.rst b/doc/user/modules/tray.rst
index c7b3b340..6485de19 100644
--- a/doc/user/modules/tray.rst
+++ b/doc/user/modules/tray.rst
@@ -33,7 +33,7 @@ Formats
The module only has a single format:
-.. setting:: format
+.. poly-setting:: format
:type: |type-format|
:tags: ````: Shows tray icons
@@ -42,21 +42,21 @@ The module only has a single format:
Settings
--------
-.. setting:: tray-spacing
+.. poly-setting:: tray-spacing
Space added between tray icons
:type: |type-extent|, non-negative
:default: ``0px``
-.. setting:: tray-padding
+.. poly-setting:: tray-padding
Space added before and after each tray icon
:type: |type-extent|, non-negative
:default: ``0px``
-.. setting:: tray-size
+.. poly-setting:: tray-size
Size of individual tray icons
@@ -65,7 +65,7 @@ Settings
:type: |type-pwo|, non-negative
:default: 66%
-.. setting:: tray-background
+.. poly-setting:: tray-background
Background color of tray icons
@@ -76,7 +76,7 @@ Settings
:type: |type-color|
:default: ``${root.background}``
-.. setting:: tray-foreground
+.. poly-setting:: tray-foreground
Tray icon color hint