Skip to content

Commit c465ec2

Browse files
committed
roman_range moved to generation.py + doc improvements
1 parent 136ff93 commit c465ec2

File tree

7 files changed

+134
-287
lines changed

7 files changed

+134
-287
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ The library basically consists in the python package `string_utils`, containing
3434

3535
Plus a secondary package `tests` which includes several submodules.\
3636
Specifically one for each test suite and named according to the api to test (eg. tests for `is_ip()`
37-
will be in `test_is_ip.py` and so on)
37+
will be in `test_is_ip.py` and so on).
38+
39+
All the public API are importable directly from the main package `string_utils`, so this:
40+
41+
`from string_utils.validation import is_ip`
42+
43+
can be simplified as:
44+
45+
`from string_utils import is_ip`
3846

3947
### Api overview
4048

@@ -239,9 +247,9 @@ asciify('èéùúòóäåëýñÅÀÁÇÌÍÑÓË')
239247
# returns 'eeuuooaaeynAAACIINOE' (string is deliberately dumb in order to show char conversion)
240248
~~~~
241249

242-
**slugify**: Convert a string into formatted slug
250+
**slugify**: Convert a string into a formatted "slug"
243251
~~~~
244-
slugify('Top 10 Reasons To Love Dogs') # returns: 'top-10-reasons-to-love-dogs'
252+
slugify('Top 10 Reasons To Love Dogs!!!') # returns: 'top-10-reasons-to-love-dogs'
245253
~~~~
246254

247255
**booleanize**: Convert a string into a boolean based on its content

docs/conf.py

Lines changed: 10 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
#
4-
# Python String Utils documentation build configuration file, created by
5-
# sphinx-quickstart on Thu Jul 30 16:08:10 2015.
6-
#
7-
# This file is execfile()d with the current directory set to its
8-
# containing dir.
9-
#
10-
# Note that not all possible configuration values are present in this
11-
# autogenerated file.
12-
#
13-
# All configuration values have a default; values that are commented out
14-
# serve to show the default.
153

164
import os
175
import sys
@@ -21,18 +9,10 @@
219
# documentation root, use os.path.abspath to make it absolute, like shown here.
2210
sys.path.insert(0, os.path.abspath('./..'))
2311

24-
# -- General configuration ------------------------------------------------
25-
26-
# If your documentation needs a minimal Sphinx version, state it here.
27-
# needs_sphinx = '1.0'
28-
2912
# Add any Sphinx extension module names here, as strings. They can be
3013
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3114
# ones.
32-
extensions = [
33-
'sphinx.ext.autodoc',
34-
'sphinx_rtd_theme',
35-
]
15+
extensions = ['sphinx.ext.autodoc', 'sphinx_rtd_theme']
3616

3717
# Add any paths that contain templates here, relative to this directory.
3818
templates_path = ['_templates']
@@ -42,9 +22,6 @@
4222
# source_suffix = ['.rst', '.md']
4323
source_suffix = '.rst'
4424

45-
# The encoding of source files.
46-
# source_encoding = 'utf-8-sig'
47-
4825
# The master toctree document.
4926
master_doc = 'index'
5027

@@ -53,12 +30,9 @@
5330
copyright = '2016-2020, Davide Zanotti'
5431
author = 'Davide Zanotti'
5532

56-
# The version info for the project you're documenting, acts as replacement for
57-
# |version| and |release|, also used in various other places throughout the
58-
# built documents.
59-
#
6033
# The short X.Y version.
6134
version = '1.0.0'
35+
6236
# The full version, including alpha/beta/rc tags.
6337
release = '1.0.0'
6438

@@ -69,218 +43,40 @@
6943
# Usually you set "language" from the command line for these cases.
7044
language = None
7145

72-
# There are two options for replacing |today|: either, you set today to some
73-
# non-false value, then it is used:
74-
# today = ''
75-
# Else, today_fmt is used as the format for a strftime call.
76-
# today_fmt = '%B %d, %Y'
77-
7846
# List of patterns, relative to source directory, that match files and
7947
# directories to ignore when looking for source files.
80-
exclude_patterns = ['build', '.venv', '.tox', 'htmlcov']
81-
82-
# The reST default role (used for this markup: `text`) to use for all
83-
# documents.
84-
# default_role = None
85-
86-
# If true, '()' will be appended to :func: etc. cross-reference text.
87-
# add_function_parentheses = True
88-
89-
# If true, the current module name will be prepended to all description
90-
# unit titles (such as .. function::).
91-
# add_module_names = True
92-
93-
# If true, sectionauthor and moduleauthor directives will be shown in the
94-
# output. They are ignored by default.
95-
# show_authors = False
96-
97-
# The name of the Pygments (syntax highlighting) style to use.
98-
pygments_style = 'sphinx'
99-
100-
# A list of ignored prefixes for module index sorting.
101-
# modindex_common_prefix = []
102-
103-
# If true, keep warnings as "system message" paragraphs in the built documents.
104-
# keep_warnings = False
48+
exclude_patterns = ['build', '_build', '_templates', '.venv', '.tox', 'htmlcov']
10549

10650
# If true, `todo` and `todoList` produce output, else they produce nothing.
10751
todo_include_todos = False
10852

109-
# -- Options for HTML output ----------------------------------------------
110-
11153
# The theme to use for HTML and HTML Help pages. See the documentation for
11254
# a list of builtin themes.
11355
html_theme = 'sphinx_rtd_theme'
11456

115-
# Theme options are theme-specific and customize the look and feel of a theme
116-
# further. For a list of options available for each theme, see the
117-
# documentation.
118-
# html_theme_options = {}
119-
120-
# Add any paths that contain custom themes here, relative to this directory.
121-
# html_theme_path = []
122-
123-
# The name for this set of Sphinx documents. If None, it defaults to
124-
# "<project> v<release> documentation".
125-
# html_title = None
126-
127-
# A shorter title for the navigation bar. Default is the same as html_title.
128-
# html_short_title = None
129-
130-
# The name of an image file (relative to this directory) to place at the top
131-
# of the sidebar.
132-
# html_logo = None
133-
134-
# The name of an image file (within the static path) to use as favicon of the
135-
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136-
# pixels large.
137-
# html_favicon = None
138-
139-
# Add any paths that contain custom static files (such as style sheets) here,
140-
# relative to this directory. They are copied after the builtin static files,
141-
# so a file named "default.css" will overwrite the builtin "default.css".
142-
# html_static_path = ['_static']
143-
144-
# Add any extra paths that contain custom files (such as robots.txt or
145-
# .htaccess) here, relative to this directory. These files are copied
146-
# directly to the root of the documentation.
147-
# html_extra_path = []
148-
149-
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
150-
# using the given strftime format.
151-
# html_last_updated_fmt = '%b %d, %Y'
152-
153-
# If true, SmartyPants will be used to convert quotes and dashes to
154-
# typographically correct entities.
155-
# html_use_smartypants = True
156-
157-
# Custom sidebar templates, maps document names to template names.
158-
# html_sidebars = {}
159-
160-
# Additional templates that should be rendered to pages, maps page names to
161-
# template names.
162-
# html_additional_pages = {}
163-
164-
# If false, no module index is generated.
165-
# html_domain_indices = True
166-
167-
# If false, no index is generated.
168-
# html_use_index = True
169-
170-
# If true, the index is split into individual pages for each letter.
171-
# html_split_index = False
172-
173-
# If true, links to the reST sources are added to the pages.
174-
# html_show_sourcelink = True
175-
176-
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
177-
# html_show_sphinx = True
178-
179-
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
180-
# html_show_copyright = True
181-
182-
# If true, an OpenSearch description file will be output, and all pages will
183-
# contain a <link> tag referring to it. The value of this option must be the
184-
# base URL from which the finished HTML is served.
185-
# html_use_opensearch = ''
186-
187-
# This is the file name suffix for HTML files (e.g. ".xhtml").
188-
# html_file_suffix = None
189-
190-
# Language to be used for generating the HTML full-text search index.
191-
# Sphinx supports the following languages:
192-
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
193-
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
194-
# html_search_language = 'en'
195-
196-
# A dictionary with options for the search language support, empty by default.
197-
# Now only 'ja' uses this config value
198-
# html_search_options = {'type': 'default'}
199-
200-
# The name of a javascript file (relative to the configuration directory) that
201-
# implements a search results scorer. If empty, the default will be used.
202-
# html_search_scorer = 'scorer.js'
203-
204-
# Output file base name for HTML help builder.
205-
htmlhelp_basename = 'PythonStringUtilsdoc'
206-
207-
# -- Options for LaTeX output ---------------------------------------------
208-
209-
latex_elements = {
210-
# The paper size ('letterpaper' or 'a4paper').
211-
# 'papersize': 'letterpaper',
212-
213-
# The font size ('10pt', '11pt' or '12pt').
214-
# 'pointsize': '10pt',
215-
216-
# Additional stuff for the LaTeX preamble.
217-
# 'preamble': '',
218-
219-
# Latex figure (float) alignment
220-
# 'figure_align': 'htbp',
57+
html_theme_options = {
58+
'collapse_navigation': False,
22159
}
22260

61+
latex_elements = {}
62+
22363
# Grouping the document tree into LaTeX files. List of tuples
22464
# (source start file, target name, title,
22565
# author, documentclass [howto, manual, or own class]).
22666
latex_documents = [
227-
(master_doc, 'PythonStringUtils.tex', 'Python String Utils Documentation',
228-
'Davide Zanotti', 'manual'),
67+
(master_doc, 'PythonStringUtils.tex', 'Python String Utils Documentation', 'Davide Zanotti', 'manual'),
22968
]
23069

231-
# The name of an image file (relative to this directory) to place at the top of
232-
# the title page.
233-
# latex_logo = None
234-
235-
# For "manual" documents, if this is true, then toplevel headings are parts,
236-
# not chapters.
237-
# latex_use_parts = False
238-
239-
# If true, show page references after internal links.
240-
# latex_show_pagerefs = False
241-
242-
# If true, show URL addresses after external links.
243-
# latex_show_urls = False
244-
245-
# Documents to append as an appendix to all manuals.
246-
# latex_appendices = []
247-
248-
# If false, no module index is generated.
249-
# latex_domain_indices = True
250-
251-
252-
# -- Options for manual page output ---------------------------------------
253-
25470
# One entry per manual page. List of tuples
25571
# (source start file, name, description, authors, manual section).
25672
man_pages = [
257-
(master_doc, 'pythonstringutils', 'Python String Utils Documentation',
258-
[author], 1)
73+
(master_doc, 'pythonstringutils', 'Python String Utils Documentation', [author], 1)
25974
]
26075

261-
# If true, show URL addresses after external links.
262-
# man_show_urls = False
263-
264-
265-
# -- Options for Texinfo output -------------------------------------------
266-
26776
# Grouping the document tree into Texinfo files. List of tuples
26877
# (source start file, target name, title, author,
26978
# dir menu entry, description, category)
27079
texinfo_documents = [
27180
(master_doc, 'PythonStringUtils', 'Python String Utils Documentation',
272-
author, 'PythonStringUtils', 'One line description of project.',
273-
'Miscellaneous'),
81+
author, 'PythonStringUtils', 'One line description of project.', 'Miscellaneous'),
27482
]
275-
276-
# Documents to append as an appendix to all manuals.
277-
# texinfo_appendices = []
278-
279-
# If false, no module index is generated.
280-
# texinfo_domain_indices = True
281-
282-
# How to display URL addresses: 'footnote', 'no', or 'inline'.
283-
# texinfo_show_urls = 'footnote'
284-
285-
# If true, do not generate a @detailmenu in the "Top" node's menu.
286-
# texinfo_no_detailmenu = False

docs/index.rst

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1-
.. Python String Utils documentation master file, created by
2-
sphinx-quickstart on Thu Jul 30 16:08:10 2015.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
5-
61
Python String Utils Documentation
72
=================================
83

9-
Contents:
10-
114
.. toctree::
12-
:maxdepth: 2
5+
:maxdepth: 3
6+
7+
8+
String Validation
9+
-----------------
1310

1411
.. automodule:: string_utils.validation
1512
:members:
13+
:undoc-members:
14+
:show-inheritance:
15+
16+
17+
String Manipulation
18+
-------------------
1619

1720
.. automodule:: string_utils.manipulation
1821
:members:
22+
:undoc-members:
23+
:show-inheritance:
24+
25+
26+
String Generation
27+
-----------------
1928

2029
.. automodule:: string_utils.generation
2130
:members:
31+
:undoc-members:
32+
:show-inheritance:
33+
2234

23-
Indices and tables
24-
==================
35+
Exceptions
36+
----------
37+
38+
.. automodule:: string_utils.errors
39+
:members:
40+
:undoc-members:
41+
:show-inheritance:
42+
43+
44+
Indices
45+
=======
2546

2647
* :ref:`genindex`
27-
* :ref:`modindex`
28-
* :ref:`search`
48+

string_utils/errors.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# -*- coding: utf-8 -*-
2+
from typing import Any
23

34

45
class InvalidInputError(TypeError):
5-
def __init__(self, input_data):
6-
"""
7-
Custom error used when received object is not a string as expected.
6+
"""
7+
Custom error raised when received object is not a string as expected.
8+
"""
89

10+
def __init__(self, input_data: Any):
11+
"""
912
:param input_data: Any received object
1013
"""
1114
type_name = type(input_data).__name__

0 commit comments

Comments
 (0)