Skip to content

Commit f4a303b

Browse files
committed
Started developer docs
1 parent 64dc0bf commit f4a303b

5 files changed

Lines changed: 274 additions & 0 deletions

File tree

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = PyPDFBuilder
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# This file does only contain a selection of the most common options. For a
6+
# full list see the documentation:
7+
# http://www.sphinx-doc.org/en/stable/config
8+
9+
# -- Path setup --------------------------------------------------------------
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
import os
16+
import sys
17+
sys.path.insert(0, os.path.abspath('..'))
18+
19+
20+
# -- Project information -----------------------------------------------------
21+
22+
project = 'PyPDF Builder'
23+
copyright = '2018, Thomas Schmitt'
24+
author = 'Thomas Schmitt'
25+
26+
# The short X.Y version
27+
version = '0.1'
28+
# The full version, including alpha/beta/rc tags
29+
release = '0.1'
30+
31+
32+
# -- General configuration ---------------------------------------------------
33+
34+
# If your documentation needs a minimal Sphinx version, state it here.
35+
#
36+
# needs_sphinx = '1.0'
37+
38+
# Add any Sphinx extension module names here, as strings. They can be
39+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
40+
# ones.
41+
extensions = [
42+
# 'sphinx.ext.autodoc',
43+
'sphinx.ext.napoleon',
44+
]
45+
46+
# Add any paths that contain templates here, relative to this directory.
47+
templates_path = ['_templates']
48+
49+
# The suffix(es) of source filenames.
50+
# You can specify multiple suffix as a list of string:
51+
#
52+
# source_suffix = ['.rst', '.md']
53+
source_suffix = '.rst'
54+
55+
# The master toctree document.
56+
master_doc = 'index'
57+
58+
# The language for content autogenerated by Sphinx. Refer to documentation
59+
# for a list of supported languages.
60+
#
61+
# This is also used if you do content translation via gettext catalogs.
62+
# Usually you set "language" from the command line for these cases.
63+
language = None
64+
65+
# List of patterns, relative to source directory, that match files and
66+
# directories to ignore when looking for source files.
67+
# This pattern also affects html_static_path and html_extra_path .
68+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
69+
70+
# The name of the Pygments (syntax highlighting) style to use.
71+
pygments_style = 'sphinx'
72+
73+
74+
# -- Options for HTML output -------------------------------------------------
75+
76+
# The theme to use for HTML and HTML Help pages. See the documentation for
77+
# a list of builtin themes.
78+
#
79+
html_theme = 'alabaster'
80+
81+
# Theme options are theme-specific and customize the look and feel of a theme
82+
# further. For a list of options available for each theme, see the
83+
# documentation.
84+
#
85+
# html_theme_options = {}
86+
87+
# Add any paths that contain custom static files (such as style sheets) here,
88+
# relative to this directory. They are copied after the builtin static files,
89+
# so a file named "default.css" will overwrite the builtin "default.css".
90+
html_static_path = ['_static']
91+
92+
# Custom sidebar templates, must be a dictionary that maps document names
93+
# to template names.
94+
#
95+
# The default sidebars (for documents that don't match any pattern) are
96+
# defined by theme itself. Builtin themes are using these templates by
97+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
98+
# 'searchbox.html']``.
99+
#
100+
# html_sidebars = {}
101+
102+
103+
# -- Options for HTMLHelp output ---------------------------------------------
104+
105+
# Output file base name for HTML help builder.
106+
htmlhelp_basename = 'PyPDFBuilderdoc'
107+
108+
109+
# -- Options for LaTeX output ------------------------------------------------
110+
111+
latex_elements = {
112+
# The paper size ('letterpaper' or 'a4paper').
113+
#
114+
# 'papersize': 'letterpaper',
115+
116+
# The font size ('10pt', '11pt' or '12pt').
117+
#
118+
# 'pointsize': '10pt',
119+
120+
# Additional stuff for the LaTeX preamble.
121+
#
122+
# 'preamble': '',
123+
124+
# Latex figure (float) alignment
125+
#
126+
# 'figure_align': 'htbp',
127+
}
128+
129+
# Grouping the document tree into LaTeX files. List of tuples
130+
# (source start file, target name, title,
131+
# author, documentclass [howto, manual, or own class]).
132+
latex_documents = [
133+
(master_doc, 'PyPDFBuilder.tex', 'PyPDF Builder Documentation',
134+
'Thomas Schmitt', 'manual'),
135+
]
136+
137+
138+
# -- Options for manual page output ------------------------------------------
139+
140+
# One entry per manual page. List of tuples
141+
# (source start file, name, description, authors, manual section).
142+
man_pages = [
143+
(master_doc, 'pypdfbuilder', 'PyPDF Builder Documentation',
144+
[author], 1)
145+
]
146+
147+
148+
# -- Options for Texinfo output ----------------------------------------------
149+
150+
# Grouping the document tree into Texinfo files. List of tuples
151+
# (source start file, target name, title, author,
152+
# dir menu entry, description, category)
153+
texinfo_documents = [
154+
(master_doc, 'PyPDFBuilder', 'PyPDF Builder Documentation',
155+
author, 'PyPDFBuilder', 'One line description of project.',
156+
'Miscellaneous'),
157+
]
158+
159+
160+
# -- Extension configuration -------------------------------------------------

docs/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. PyPDF Builder documentation master file, created by
2+
sphinx-quickstart on Tue Apr 24 14:28:51 2018.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to PyPDF Builder's documentation!
7+
=========================================
8+
9+
.. automodule:: pypdfbuilder
10+
:members:
11+
12+
.. toctree::
13+
:maxdepth: 2
14+
:caption: Contents:
15+
16+
17+
18+
Indices and tables
19+
==================
20+
21+
* :ref:`genindex`
22+
* :ref:`modindex`
23+
* :ref:`search`

docs/make.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
set SPHINXPROJ=PyPDFBuilder
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd

pypdfbuilder.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,50 @@
1616

1717

1818
class PDFInfo:
19+
'''File info class for PDF files.
20+
21+
Instances of this class show information about PDF files that are being edited in
22+
PyPDF Builder.
23+
24+
Args:
25+
filepath (str): Path to PDF File
26+
'''
1927
def __init__(self, filepath):
2028
self.__filepath = filepath
2129

2230
@property
2331
def pages(self):
32+
'''int: Number of pages contained in PDF file'''
2433
with open(self.__filepath, 'rb') as in_pdf:
2534
pdf_handler = PdfFileReader(in_pdf)
2635
return pdf_handler.getNumPages()
2736

2837
def concat_filename(self, max_length=35):
38+
'''Concatenate a filename to a certain length.
39+
40+
Args:
41+
max_length (int): Maximum length of concatenated string (default: 35)
42+
43+
Returns:
44+
str: Filename of PDFInfo-object concatenated to max length of `max_length`
45+
46+
'''
2947
basename = os.path.basename(self.__filepath)
3048
concat_filename = f'{basename[0:35]}'
3149
if len(basename) > max_length:
3250
concat_filename += '…'
3351
return concat_filename
3452

3553
def pdf_info_string(self, concat_length=35):
54+
'''Fetch a standard info-string about the PDFInfo-object.
55+
56+
Args:
57+
concat_length (int): Maximum length of concatenated filename string (default: 35)
58+
59+
Returns:
60+
str: Information in the format `Filename (pages)` of PDFInfo-object
61+
62+
'''
3663
concat_filename = self.concat_filename(max_length=concat_length)
3764
return f'{concat_filename} ({self.pages} pages)'
3865

@@ -117,6 +144,13 @@ def save_as(self):
117144

118145

119146
class SplitTabManager:
147+
'''Manager class for the Split Tab
148+
149+
The instance of this class manages all aspects of the split tab in the program.
150+
151+
Args:
152+
parent (PyPDFBuilderApplication): Application that created the instance and that contains the Split Tab.
153+
'''
120154
def __init__(self, parent=None):
121155
self.parent = parent
122156
self.__split_filepath = None
@@ -125,6 +159,7 @@ def __init__(self, parent=None):
125159

126160
@property
127161
def parent(self):
162+
'''PyPDFBuilderApplication: Application that created the instance and that contains the Split Tab.'''
128163
return self.__parent
129164

130165
@parent.setter

0 commit comments

Comments
 (0)