|
5 | 5 | Operators without Built-in Meanings |
6 | 6 |
|
7 | 7 | Not all operators recognized by the Mathics3 are associated with functions that have built‐in meanings. |
8 | | -You can use these operators as a way to build up your own notation within the Mathics3. |
| 8 | +You can use these operators as a way to build up your own notation within Mathics3. |
9 | 9 | """ |
10 | 10 |
|
11 | | -from mathics.core.attributes import A_NO_ATTRIBUTES |
12 | | -from mathics.core.builtin import InfixOperator |
| 11 | +from inspect import getmembers, isclass |
| 12 | +from sys import modules |
13 | 13 |
|
| 14 | +from mathics.core.builtin import OPERATOR_DATA, NoMeaningInfixOperator |
14 | 15 |
|
15 | | -class Star(InfixOperator): |
16 | | - r""" |
17 | | - Star <url> |
18 | | - :WML link: |
19 | | - https://reference.wolfram.com/language/ref/Star.html</url> |
| 16 | +# Note: classes in this file must *only* be "no-meaning" |
| 17 | +# builtin operator classes. |
20 | 18 |
|
21 | | - <dl> |
22 | | - <dt>'Star[$x$, $y$, ...]' |
23 | | - <dd>displays $x$ ⋆ $y$ ⋆ ... |
24 | | - </dl> |
25 | 19 |
|
26 | | - >> Star[x, y, z] |
27 | | - = x ⋆ y ⋆ z |
| 20 | +class Because(NoMeaningInfixOperator): |
| 21 | + r"""This text is replaced! But it needs to be here for documentation detection.""" |
28 | 22 |
|
29 | | - >> a \[Star] b |
30 | | - = a ⋆ b |
31 | | - """ |
32 | 23 |
|
33 | | - attributes = A_NO_ATTRIBUTES |
34 | | - default_formats = False # Don't use any default format rules. Instead, see below. |
35 | | - formats = { |
36 | | - (("InputForm", "OutputForm", "StandardForm"), "Star[args__]"): ( |
37 | | - 'Infix[{args}, "⋆"]' |
38 | | - ), |
39 | | - } |
| 24 | +class Cap(NoMeaningInfixOperator): |
| 25 | + r"""This text is replaced! But it needs to be here for documentation detection.""" |
40 | 26 |
|
41 | | - operator = "⋆" # \u22C6 |
42 | | - summary_text = "star symbol" |
| 27 | + |
| 28 | +class CenterDot(NoMeaningInfixOperator): |
| 29 | + r"""This text is replaced! But it needs to be here for documentation detection.""" |
| 30 | + |
| 31 | + |
| 32 | +class Star(NoMeaningInfixOperator): |
| 33 | + r"""This text is replaced! But it needs to be here for documentation detection.""" |
| 34 | + |
| 35 | + |
| 36 | +# Generate Builtin No-meaning Builtin Infix operators, using |
| 37 | +# the Operator name and Operator Unicode found by reading |
| 38 | +# the operators JSON file. |
| 39 | +for name, operator_class in getmembers(modules[__name__]): |
| 40 | + if isclass(operator_class): |
| 41 | + operator_name = operator_class.__name__ |
| 42 | + operator_string = OPERATOR_DATA["no-meaning-infix-operators"].get(operator_name) |
| 43 | + if operator_string is not None: |
| 44 | + operator_class.operator = operator_string |
| 45 | + operator_class.__doc__ = NoMeaningInfixOperator.__doc_pattern__.format( |
| 46 | + operator_name=operator_name, operator_string=operator_string |
| 47 | + ) |
| 48 | + operator_class.summary_text = f"""{operator_name} infix operator "{operator_string}" (no pre-set meaning attached)""" |
| 49 | + operator_class.formats = { |
| 50 | + (("InputForm", "OutputForm", "StandardForm"), f"{operator_name}[args__]"): ( |
| 51 | + ('Infix[{args}, "%s"]' % operator_string) |
| 52 | + ) |
| 53 | + } |
0 commit comments