From 74708ea9ad812daaf7e03e61dc5164a1f2548265 Mon Sep 17 00:00:00 2001 From: Hong Minhee Date: Fri, 17 Aug 2018 23:50:36 +0900 Subject: [PATCH] Adjust docs & changelog for PR #271 https://github.com/nirum-lang/nirum/pull/271 --- CHANGES.md | 4 +++- docs/annotation.md | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0e0e3f2..f1cecf9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,9 @@ To be released. - The `uri` type has completly gone; use `url` instead. [[#126], [#281] by Jonghun Park] - - Added constraints for numeric unboxed types. [[#206], [#271]] + - Added [`@numeric-constraints`](docs/annotation.md#numeric-constraints) + annotation to constraint the range of unboxed types' values. + [[#206], [#271] by Seunghun Lee] ### Docs target diff --git a/docs/annotation.md b/docs/annotation.md index e22e414..ed0b1a3 100644 --- a/docs/annotation.md +++ b/docs/annotation.md @@ -132,12 +132,14 @@ class FileNotReadable(FileError): ### `@numeric-constraints` {#numeric-constraints} -`@numeric-constraints` annotation constrain the range of the input value. +`@numeric-constraints` annotation constrains the range of unboxed types' values. Currently, available annotation arguments are below: -`min`: Minimum input value; inclusive +`min` +: Minimum input value; inclusive. -`max`: Maximum input value; inclusive +`max` +: Maximum input value; inclusive. For example, the following first Nirum code is compiled to the second Python code: @@ -148,13 +150,11 @@ unboxed month (int32); ~~~~~~~~ ~~~~~~~~ python -class Month(object): - ... - def __init__(self, value: '__builtin__.int') -> None: - ... - if not (value <= (12)): +class Month: + def __init__(self, value: int) -> None: + if not value <= 12: raise ValueError("value is greater than 12") - if not (value >= (1)): + if not value >= 1: raise ValueError("value is less than 1") ... ~~~~~~~~