Skip to content

Commit

Permalink
Documentation improvements (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Mar 6, 2022
1 parent d05cf47 commit e4681fa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
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.
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

0 comments on commit e4681fa

Please sign in to comment.