chiark / gitweb /
documentation/python: dedicated test for value formatting.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 7 May 2020 20:07:19 +0000 (22:07 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 7 May 2020 20:12:09 +0000 (22:12 +0200)
documentation/test_python/inspect_string/inspect_string.html
documentation/test_python/inspect_string/inspect_string/__init__.py
documentation/test_python/inspect_value_formatting/inspect_value_formatting.html [new file with mode: 0644]
documentation/test_python/inspect_value_formatting/inspect_value_formatting.py [new file with mode: 0644]
documentation/test_python/test_inspect.py

index bfc5bb3884495d7a629494ed92bb45878bf0b3e8..fb0bcb1a01b674b39cc7f2b9aa86336a4d5ffcd7 100644 (file)
               <a href="#A_CONSTANT" class="m-doc-self">A_CONSTANT</a> = 3.24
             </dt>
             <dd></dd>
-            <dt id="A_FALSE_VALUE">
-              <a href="#A_FALSE_VALUE" class="m-doc-self">A_FALSE_VALUE</a> = False
-            </dt>
-            <dd></dd>
-            <dt id="A_NONE_VALUE">
-              <a href="#A_NONE_VALUE" class="m-doc-self">A_NONE_VALUE</a> = None
-            </dt>
-            <dd></dd>
-            <dt id="A_ZERO_VALUE">
-              <a href="#A_ZERO_VALUE" class="m-doc-self">A_ZERO_VALUE</a> = 0
-            </dt>
-            <dd></dd>
-            <dt id="ENUM_THING">
-              <a href="#ENUM_THING" class="m-doc-self">ENUM_THING</a> = <a href="inspect_string.html#MyEnum-YAY" class="m-doc">MyEnum.YAY</a>
-            </dt>
-            <dd></dd>
-            <dt id="LARGE_VALUE_WILL_BE_AN_ELLIPSIS">
-              <a href="#LARGE_VALUE_WILL_BE_AN_ELLIPSIS" class="m-doc-self">LARGE_VALUE_WILL_BE_AN_ELLIPSIS</a> = …
-            </dt>
-            <dd></dd>
             <dt id="foo">
               <a href="#foo" class="m-doc-self">foo</a>
             </dt>
index 68ce6ac91357072ebb86f7fabd2de40715f90f17..89ae9321ac7d1d74770860498cdf587033625d81 100644 (file)
@@ -131,22 +131,6 @@ def function():
 
 A_CONSTANT = 3.24
 
-# TODO: not visible ATM, need to figure out interaction with __all__
-DATA_DECLARATION: int
-
-ENUM_THING = MyEnum.YAY
-
-# These should have their value shown in the docs as well, even though they are
-# not true-ish
-A_ZERO_VALUE = 0
-A_FALSE_VALUE = False
-A_NONE_VALUE = None
-
-# This value is too long and should be completely omitted
-LARGE_VALUE_WILL_BE_AN_ELLIPSIS = """Lorem ipsum dolor sit amet, consectetur
-    adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
-    magna aliqua."""
-
 _PRIVATE_CONSTANT = -3
 
 foo = Foo()
diff --git a/documentation/test_python/inspect_value_formatting/inspect_value_formatting.html b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.html
new file mode 100644 (file)
index 0000000..f89eac7
--- /dev/null
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>inspect_value_formatting | My Python Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Python Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          inspect_value_formatting <span class="m-thin">module</span>
+        </h1>
+        <p>Value and default argument formatting</p>
+        <div class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#enums">Enums</a></li>
+                <li><a href="#functions">Functions</a></li>
+                <li><a href="#data">Data</a></li>
+              </ul>
+            </li>
+          </ul>
+        </div>
+        <section id="enums">
+          <h2><a href="#enums">Enums</a></h2>
+          <dl class="m-doc">
+            <dt id="MyEnum">
+              <span class="m-doc-wrap-bumper">class <a href="#MyEnum" class="m-doc-self">MyEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="#MyEnum-YAY" class="m-doc-self" id="MyEnum-YAY">YAY</a> = 2</span>
+            </dt>
+            <dd></dd>
+          </dl>
+        </section>
+        <section id="functions">
+          <h2><a href="#functions">Functions</a></h2>
+          <dl class="m-doc">
+            <dt id="basics">
+              <span class="m-doc-wrap-bumper">def <a href="#basics" class="m-doc-self">basics</a>(</span><span class="m-doc-wrap">string_param = &#x27;string&#x27;,
+              tuple_param = (3, 5),
+              float_param = 1.2)</span>
+            </dt>
+            <dd></dd>
+            <dt id="setup_callback">
+              <span class="m-doc-wrap-bumper">def <a href="#setup_callback" class="m-doc-self">setup_callback</a>(</span><span class="m-doc-wrap">callback = &lt;function basics at 0x7fc2ca424ee0&gt;)</span>
+            </dt>
+            <dd>Should produce a deterministic output.</dd>
+          </dl>
+        </section>
+        <section id="data">
+          <h2><a href="#data">Data</a></h2>
+          <dl class="m-doc">
+            <dt id="A_FALSE_VALUE">
+              <a href="#A_FALSE_VALUE" class="m-doc-self">A_FALSE_VALUE</a> = False
+            </dt>
+            <dd></dd>
+            <dt id="A_NONE_VALUE">
+              <a href="#A_NONE_VALUE" class="m-doc-self">A_NONE_VALUE</a> = None
+            </dt>
+            <dd></dd>
+            <dt id="A_ZERO_VALUE">
+              <a href="#A_ZERO_VALUE" class="m-doc-self">A_ZERO_VALUE</a> = 0
+            </dt>
+            <dd></dd>
+            <dt id="ENUM_THING">
+              <a href="#ENUM_THING" class="m-doc-self">ENUM_THING</a> = <a href="inspect_value_formatting.html#MyEnum-YAY" class="m-doc">MyEnum.YAY</a>
+            </dt>
+            <dd></dd>
+            <dt id="LARGE_VALUE_WILL_BE_AN_ELLIPSIS">
+              <a href="#LARGE_VALUE_WILL_BE_AN_ELLIPSIS" class="m-doc-self">LARGE_VALUE_WILL_BE_AN_ELLIPSIS</a> = …
+            </dt>
+            <dd></dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/documentation/test_python/inspect_value_formatting/inspect_value_formatting.py b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.py
new file mode 100644 (file)
index 0000000..d2b807d
--- /dev/null
@@ -0,0 +1,29 @@
+"""Value and default argument formatting"""
+
+import enum
+
+def basics(string_param = "string", tuple_param = (3, 5), float_param = 1.2):
+    pass
+
+def setup_callback(callback = basics):
+    """Should produce a deterministic output."""
+    pass
+
+# TODO: not visible ATM, need to figure out interaction with __all__
+DATA_DECLARATION: int
+
+class MyEnum(enum.Enum):
+    YAY = 2
+
+ENUM_THING = MyEnum.YAY
+
+# These should have their value shown in the docs as well, even though they are
+# not true-ish
+A_ZERO_VALUE = 0
+A_FALSE_VALUE = False
+A_NONE_VALUE = None
+
+# This value is too long and should be completely omitted
+LARGE_VALUE_WILL_BE_AN_ELLIPSIS = """Lorem ipsum dolor sit amet, consectetur
+    adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
+    magna aliqua."""
index 57599dba6afa2c6698ff6f041c7a90c78dd91776..7ecf427856986c3179b2828acf128f3d1af9373f 100644 (file)
@@ -252,3 +252,8 @@ class Underscored(BaseInspectTestCase):
 
         self.assertEqual(*self.actual_expected_contents('inspect_underscored.html'))
         self.assertEqual(*self.actual_expected_contents('inspect_underscored.Class.html'))
+
+class ValueFormatting(BaseInspectTestCase):
+    def test(self):
+        self.run_python({})
+        self.assertEqual(*self.actual_expected_contents('inspect_value_formatting.html'))