blueloveTH hace 1 año
padre
commit
8720c22c8a
Se han modificado 3 ficheros con 15 adiciones y 7 borrados
  1. 13 1
      docs/C-API/introduction.md
  2. 0 4
      include/pocketpy/pocketpy.h
  3. 2 2
      scripts/gen_docs.py

+ 13 - 1
docs/C-API/introduction.md

@@ -4,4 +4,16 @@ icon: dot
 order: 10
 order: 10
 ---
 ---
 
 
-TBA
+TBA
+
+
+### `PY_RAISE` macro
+
+Mark a function that can raise an exception on failure.
+
++ If the function returns `bool`, then `false` means an exception is raised.
++ If the function returns `int`, then `-1` means an exception is raised.
+
+### `PY_RETURN` macro
+
+Mark a function that can store a value in `py_retval()` on success.

+ 0 - 4
include/pocketpy/pocketpy.h

@@ -34,11 +34,7 @@ typedef struct c11_sv {
     int size;
     int size;
 } c11_sv;
 } c11_sv;
 
 
-/// Mark a function that can raise an exception.
-/// + If the function returns `bool`, then `false` means an exception is raised.
-/// + If the function returns `int`, then `-1` means an exception is raised.
 #define PY_RAISE
 #define PY_RAISE
-/// Mark a function that returns a value by `py_retval()` on success.
 #define PY_RETURN
 #define PY_RETURN
 
 
 /// A generic reference to a python object.
 /// A generic reference to a python object.

+ 2 - 2
scripts/gen_docs.py

@@ -19,9 +19,9 @@ class Function:
     def badges(self):
     def badges(self):
         res = []
         res = []
         if self.is_py_raise:
         if self.is_py_raise:
-            res.append('[!badge text="raise" variant="danger"]')
+            res.append('[!badge text="raise" variant="danger"](../introduction/#py_raise-macro)')
         if self.is_py_return:
         if self.is_py_return:
-            res.append('[!badge text="return"]')
+            res.append('[!badge text="return"](../introduction/#py_return-macro)')
         return ' '.join(res)
         return ' '.join(res)
 
 
     def markdown(self):
     def markdown(self):