Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation improvements #254

Merged
merged 3 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ human-readable size or throughput. It is localized to:

[https://python-humanize.readthedocs.io](https://python-humanize.readthedocs.io)

<!-- usage-start -->

## Usage

### Integer humanization
Expand Down Expand Up @@ -198,6 +200,8 @@ FileNotFoundError: [Errno 2] No translation file found for domain: 'humanize'
<gettext.GNUTranslations instance ...>
```

<!-- usage-end -->

How to add new phrases to existing locale files:

```console
Expand Down
10 changes: 10 additions & 0 deletions docs/css/code_select.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Don't allow to select >>> in ```pycon``` code blocks */
.language-pycon .gp,
.language-pycon .go {
user-select: none;
}

/* Hide "Copy to clipboard" buttons in ```pycon``` code blocks */
.highlight.language-pycon .md-clipboard {
display: none;
}
8 changes: 6 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ Welcome to the humanize API reference.
* [Filesize](filesize)
* [I18n](i18n)

For usage examples see
[README.md](https://github.com/jmoiron/humanize/blob/master/README.md).
{%
include-markdown "../README.md"
start="<!-- usage-start -->"
end="<!-- usage-end -->"
comments=false
%}
5 changes: 4 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mkdocs>=1.1
mkdocs-material
mkdocstrings
mkdocstrings[python-legacy]>=0.18
mkdocs-include-markdown-plugin
pygments
pymdown-extensions>=9.2
12 changes: 11 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ site_name: humanize
site_url: https://python-humanize.readthedocs.io
repo_url: https://github.com/jmoiron/humanize
theme:
name: "material"
name: material

nav:
- Home: index.md
Expand All @@ -16,3 +16,13 @@ plugins:
- mkdocstrings:
watch:
- src/humanize
- include-markdown

markdown_extensions:
- pymdownx.highlight:
use_pygments: true
pygments_lang_class: true
- pymdownx.superfences

extra_css:
- css/code_select.css
6 changes: 3 additions & 3 deletions src/humanize/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,13 @@ def clamp(value, format="{:}", floor=None, ceil=None, floor_token="<", ceil_toke
Args:
value (int, float): Input number.
format (str OR callable): Can either be a formatting string, or a callable
function than receives value and returns a string.
function that receives value and returns a string.
floor (int, float): Smallest value before clamping.
ceil (int, float): Largest value before clamping.
floor_token (str): If value is smaller than floor, token will be prepended
to output.
to output.
mondeja marked this conversation as resolved.
Show resolved Hide resolved
ceil_token (str): If value is larger than ceil, token will be prepended
to output.
to output.

Returns:
str: Formatted number. The output is clamped between the indicated floor and
Expand Down