Skip to content

Commit

Permalink
Prepare for documentation and manuals (#84)
Browse files Browse the repository at this point in the history
- Separate command line args from main
- Add framework to build documentation
  and manuals using sphinx
- Fix MANIFEST file for python build
  • Loading branch information
hsbasu authored Oct 19, 2024
1 parent 6232eed commit c8e48d1
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include debian/changelog
global-exclude *.py[cod]
graft data*
graft po*
include src/battery-monitor.in
include src/theme-manager.in
graft src/ThemeManager/ui*
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
7 changes: 7 additions & 0 deletions docs/ThemeManager.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Description
===========

.. argparse::
:module: ThemeManager.cli_args
:func: command_line_args
:prog: theme-manager
47 changes: 47 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'theme-manager'
copyright = 'Copyright (C) 2024 Himadri Sekhar Basu'
author = 'Himadri Sekhar Basu <hsb10@iitbbs.ac.in>'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinxarg.ext'
]

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', project, 'Theme Manager', [author], 1)
]
16 changes: 16 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. Battery Monitor documentation master file, created by
sphinx-quickstart on Sun Mar 3 09:21:34 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Theme Manager documentation!
===========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

modules

Indices and tables
==================
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Synopsis
========

.. toctree::
:maxdepth: 1

ThemeManager
49 changes: 49 additions & 0 deletions src/ThemeManager/cli_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) 2021-2024 Himadri Sekhar Basu <hsb10@iitbbs.ac.in>
#
# This file is part of theme-manager.
#
# theme-manager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# theme-manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with theme-manager. If not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301, USA..
#
# Author: Himadri Sekhar Basu <hsb10@iitbbs.ac.in>
#

# import the necessary modules!
import argparse
import gettext
import locale

# imports from current package
from ThemeManager.common import APP, LOCALE_DIR


# i18n
locale.bindtextdomain(APP, LOCALE_DIR)
gettext.bindtextdomain(APP, LOCALE_DIR)
gettext.textdomain(APP)
_ = gettext.gettext

description = _('A Python3-based GUI application to change different colour variants of GTK, Icon, Cursor and other themes.')

def command_line_args():
# Parse arguments
parser = argparse.ArgumentParser(prog=APP, description=description, conflict_handler='resolve')

# parser.add_argument('', action='store_true', dest='start_window', default=True, help=("Start Theme Manager window"))
parser.add_argument('-i', '--indicator', action='store_true', dest='start_indicator', default=False, help=("Start Theme Manager Indicator"))
parser.add_argument('-v', '--verbose', action='store_true', dest='show_debug', default=False, help=("Print debug messages to stdout i.e. terminal"))
parser.add_argument('-V', '--version', action='store_true', dest='show_version', default=False, help=("Show version and exit"))

return parser
12 changes: 3 additions & 9 deletions src/ThemeManager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

# imports from current package
from ThemeManager.common import APP, LOCALE_DIR, LOGFILE, __version__
from ThemeManager.cli_args import command_line_args
from ThemeManager.indicator import TMIndicator
from ThemeManager.gui import run_TMwindow

Expand All @@ -39,17 +40,10 @@
gettext.textdomain(APP)
_ = gettext.gettext

description = 'A Python3-based GUI application to change different colour variants of GTK, Icon, Cursor and other themes.'

# Parse arguments
parser = argparse.ArgumentParser(prog=APP, description=description, conflict_handler='resolve')

# parser.add_argument('', action='store_true', dest='start_window', default=True, help=("Start Theme Manager window"))
parser.add_argument('-i', '--indicator', action='store_true', dest='start_indicator', default=False, help=("Start Theme Manager Indicator"))
parser.add_argument('-v', '--verbose', action='store_true', dest='show_debug', default=False, help=("Print debug messages to stdout i.e. terminal"))
parser.add_argument('-V', '--version', action='store_true', dest='show_version', default=False, help=("Show version and exit"))

parser = command_line_args()
args = parser.parse_args()

args.start_window = True

if args.show_version:
Expand Down

0 comments on commit c8e48d1

Please sign in to comment.