Skip to content

Commit 984c262

Browse files
authored
Have @mtkmodel docs show up under the "Basics" section (#2285)
1 parent 1aa4806 commit 984c262

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

docs/pages.jl

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pages = [
2121
"basics/Composition.md",
2222
"basics/Events.md",
2323
"basics/Linearization.md",
24+
"basics/MTKModel_Connector.md",
2425
"basics/Validation.md",
2526
"basics/DependencyGraphs.md",
2627
"basics/FAQ.md"],

docs/src/basics/MTKModel_Connector.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## Defining components with `@mtkmodel`
1+
# Defining components with `@mtkmodel`
22

33
`@mtkmodel` is a convenience macro to define ModelingToolkit components. It returns `ModelingToolkit.Model`, which includes a constructor that returns an ODESystem, a `structure` dictionary with metadata and flag `isconnector` which is set to `false`.
44

5-
### What can an MTK-Model definition have?
5+
## What can an MTK-Model definition have?
66

77
`@mtkmodel` definition contains begin blocks of
88

@@ -52,7 +52,7 @@ end
5252
end
5353
```
5454

55-
#### `@parameters` and `@variables` begin block
55+
### `@parameters` and `@variables` begin block
5656

5757
- Parameters and variables are declared with respective begin blocks.
5858
- Variables must be functions of an independent variable.
@@ -67,12 +67,12 @@ julia > ModelingToolkit.getdefault(model_c.v)
6767
2.0
6868
```
6969

70-
#### `@structural_parameters` begin block
70+
### `@structural_parameters` begin block
7171

7272
- This block is for non symbolic input arguements. These are for inputs that usually are not meant to be part of components; but influence how they are defined. One can list inputs like boolean flags, functions etc... here.
7373
- Whenever default values are specified, unlike parameters/variables, they are reflected in the keyword argument list.
7474

75-
#### `@extend` block
75+
### `@extend` block
7676

7777
To extend a partial system,
7878

@@ -88,7 +88,7 @@ julia> @named model_c = ModelC(; p1 = 2.0)
8888

8989
However, as `p2` isn't listed in the model definition, its default can't be modified by users.
9090

91-
#### `@components` begin block
91+
### `@components` begin block
9292

9393
- Declare the subcomponents within `@components` begin block.
9494
- The arguments in these subcomponents are promoted as keyword arguments as `subcomponent_name__argname` with `nothing` as default value.
@@ -102,7 +102,7 @@ julia> @named model_c1 = ModelC(; model_a.k1 = 1);
102102

103103
And as `k2` isn't listed in the sub-component definition of `ModelC`, its default value can't be modified by users.
104104

105-
#### `@equations` begin block
105+
### `@equations` begin block
106106

107107
- List all the equations here
108108

@@ -130,11 +130,8 @@ end
130130
`@connector`s accepts begin blocks of `@components`, `@equations`, `@extend`, `@parameters`, `@structural_parameters`, `@variables`. These keywords mean the same as described above for `@mtkmodel`.
131131

132132
!!! note
133-
134133
For more examples of usage, checkout [ModelingToolkitStandardLibrary.jl](https://github.com/SciML/ModelingToolkitStandardLibrary.jl/)
135134

136-
* * *
137-
138135
### What's a `structure` dictionary?
139136

140137
For components defined with `@mtkmodel` or `@connector`, a dictionary with metadata is created. It lists `:components` (sub-component list), `:extend` (the extended states and base system), `:parameters`, `:variables`, ``:kwargs`` (list of keyword arguments), `:independent_variable`, `:equations`.

0 commit comments

Comments
 (0)