Skip to content

Commit

Permalink
chore(lems-docs): properly indent xml
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Jun 18, 2024
1 parent 77324fb commit ae12932
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 160 deletions.
15 changes: 8 additions & 7 deletions scripts/lems/xml2md.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ def get_lems_examples(srcdirs, examples_max=5):
examples.sort(key=len, reverse=True)
# Let's only keep the first 5 examples
for example in examples:
ET.indent(example, space=" ")
if len(lems_element_examples[lems_element]) < examples_max:
lems_element_examples[lems_element].append(
ET.tostring(example, pretty_print=True,
encoding="unicode", with_comments="False"
)
)
# print(lems_element_examples)
example_string = ET.tostring(example, pretty_print=True,
encoding="unicode", with_comments="False"
)
lems_element_examples[lems_element].append(example_string)
print(example_string)
# print(lems_element_examples)


def get_schema_doc(schemafile):
Expand Down Expand Up @@ -294,7 +295,7 @@ def main(srcdir, destdir):
# print(parsed_data)

if __name__ == "__main__":
# src = "/home/asinha/Documents/02_Code/00_mine/NeuroML/software/NeuroML2/"
# src = "/home/asinha/Documents/02_Code/00_mine/NeuroML/software/LEMS/"
src = None
destdir = "../../source/Userdocs/LEMS_elements/"
main(src, destdir)
43 changes: 21 additions & 22 deletions source/Userdocs/LEMS_elements/Definingcomponenttypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,36 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<ComponentType name="Population">
<ComponentReference name="component" type="Component"/>
<Parameter name="size" dimension="none"/>
<Structure>
<MultiInstantiate number="size" component="component"/>
</Structure>
</ComponentType>
<ComponentReference name="component" type="Component"/>
<Parameter name="size" dimension="none"/>
<Structure>
<MultiInstantiate number="size" component="component"/>
</Structure>
</ComponentType>
```
```{code-block} xml
<ComponentType name="EventConnectivity">
<Link name="source" type="Population"/>
<Link name="target" type="Population"/>
<Child name="Connections" type="ConnectionPattern"/>
</ComponentType>
<Link name="source" type="Population"/>
<Link name="target" type="Population"/>
<Child name="Connections" type="ConnectionPattern"/>
</ComponentType>
```
```{code-block} xml
<ComponentType name="Network">
<Children name="populations" type="Population"/>
<Children name="connectivities" type="EventConnectivity"/>
</ComponentType>
<Children name="populations" type="Population"/>
<Children name="connectivities" type="EventConnectivity"/>
</ComponentType>
```
```{code-block} xml
<ComponentType name="AllAll" extends="ConnectionPattern">
<Structure>
<ForEach instances="../source" as="a">
<ForEach instances="../target" as="b">
<EventConnection from="a" to="b"/>
</ForEach>
</ForEach>
</Structure>
</ComponentType>
<Structure>
<ForEach instances="../source" as="a">
<ForEach instances="../target" as="b">
<EventConnection from="a" to="b"/>
</ForEach>
</ForEach>
</Structure>
</ComponentType>
```
```{code-block} xml
<ComponentType name="ConnectionPattern"/>
Expand Down
176 changes: 88 additions & 88 deletions source/Userdocs/LEMS_elements/Dynamics.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,47 +62,47 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<Dynamics>
<StateVariable name="t" dimension="time"/>
</Dynamics>
<StateVariable name="t" dimension="time"/>
</Dynamics>
```
```{code-block} xml
<Dynamics>
<StateVariable name="x" dimension="none"/>
<DerivedVariable name="ex" dimension="none" value="exp(x)"/>
<DerivedVariable name="q" dimension="none" value="ex / (1 + ex)"/>
<DerivedVariable name="rf" dimension="per_time" select="Forward/r"/>
<DerivedVariable name="rr" dimension="per_time" select="Reverse/r"/>
<TimeDerivative variable="x" value="(1 + ex)^2 / ex * (rf * (1 - q) - rr * q)"/>
<DerivedVariable name="fcond" dimension="none" exposure="fcond" value="q^power"/>
</Dynamics>
<StateVariable name="x" dimension="none"/>
<DerivedVariable name="ex" dimension="none" value="exp(x)"/>
<DerivedVariable name="q" dimension="none" value="ex / (1 + ex)"/>
<DerivedVariable name="rf" dimension="per_time" select="Forward/r"/>
<DerivedVariable name="rr" dimension="per_time" select="Reverse/r"/>
<TimeDerivative variable="x" value="(1 + ex)^2 / ex * (rf * (1 - q) - rr * q)"/>
<DerivedVariable name="fcond" dimension="none" exposure="fcond" value="q^power"/>
</Dynamics>
```
```{code-block} xml
<Dynamics>
<StateVariable name="q" dimension="none"/>
<DerivedVariable dimension="per_time" name="rf" select="Forward/r"/>
<DerivedVariable dimension="per_time" name="rr" select="Reverse/r"/>
<TimeDerivative variable="q" value="rf * (1 - q) - rr * q"/>
<DerivedVariable name="fcond" dimension="none" exposure="fcond" value="q^power"/>
</Dynamics>
<StateVariable name="q" dimension="none"/>
<DerivedVariable dimension="per_time" name="rf" select="Forward/r"/>
<DerivedVariable dimension="per_time" name="rr" select="Reverse/r"/>
<TimeDerivative variable="q" value="rf * (1 - q) - rr * q"/>
<DerivedVariable name="fcond" dimension="none" exposure="fcond" value="q^power"/>
</Dynamics>
```
```{code-block} xml
<Dynamics>
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<DerivedVariable name="totcurrent" dimension="current" select="populations[*]/current" reduce="add"/>
<StateVariable name="v" exposure="v" dimension="voltage"/>
<TimeDerivative variable="v" value="(totcurrent + injection) / capacitance"/>
</Dynamics>
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<DerivedVariable name="totcurrent" dimension="current" select="populations[*]/current" reduce="add"/>
<StateVariable name="v" exposure="v" dimension="voltage"/>
<TimeDerivative variable="v" value="(totcurrent + injection) / capacitance"/>
</Dynamics>
```
```{code-block} xml
<Dynamics>
<StateVariable name="v" exposure="v" dimension="voltage"/>
<TimeDerivative variable="v" value="leakConductance * (leakReversal - v) / capacitance"/>
<OnEvent port="spikes-in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
</Dynamics>
<StateVariable name="v" exposure="v" dimension="voltage"/>
<TimeDerivative variable="v" value="leakConductance * (leakReversal - v) / capacitance"/>
<OnEvent port="spikes-in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
</Dynamics>
```
````
`````
Expand Down Expand Up @@ -344,28 +344,28 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
```
```{code-block} xml
<OnStart>
<StateAssignment variable="geff" value="0"/>
</OnStart>
<StateAssignment variable="geff" value="0"/>
</OnStart>
```
```{code-block} xml
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
```
```{code-block} xml
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
```
```{code-block} xml
<OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
<StateAssignment variable="v" value="v0"/>
</OnStart>
```
````
`````
Expand Down Expand Up @@ -406,32 +406,32 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<OnCondition test="tsince .gt. period">
<StateAssignment variable="tsince" value="0"/>
<EventOut port="a"/>
</OnCondition>
<StateAssignment variable="tsince" value="0"/>
<EventOut port="a"/>
</OnCondition>
```
```{code-block} xml
<OnCondition test="t - tlast .gt. period">
<StateAssignment variable="tlast" value="t"/>
<EventOut port="a"/>
</OnCondition>
<StateAssignment variable="tlast" value="t"/>
<EventOut port="a"/>
</OnCondition>
```
```{code-block} xml
<OnCondition test="v .gt. threshold">
<EventOut port="out"/>
<Transition regime="refr"/>
</OnCondition>
<OnCondition test="v .gt. threshold">
<EventOut port="out"/>
<Transition regime="refr"/>
</OnCondition>
```
```{code-block} xml
<OnCondition test="t .gt. tin + refractoryPeriod">
<Transition regime="int"/>
</OnCondition>
<OnCondition test="t .gt. tin + refractoryPeriod">
<Transition regime="int"/>
</OnCondition>
```
```{code-block} xml
<OnCondition test="tsince .gt. period">
<StateAssignment variable="tsince" value="0"/>
<EventOut port="a"/>
</OnCondition>
<StateAssignment variable="tsince" value="0"/>
<EventOut port="a"/>
</OnCondition>
```
````
`````
Expand Down Expand Up @@ -482,23 +482,23 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<OnEvent port="spikes-in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
```
```{code-block} xml
<OnEvent port="in">
<StateAssignment variable="geff" value="geff + deltaG"/>
</OnEvent>
<StateAssignment variable="geff" value="geff + deltaG"/>
</OnEvent>
```
```{code-block} xml
<OnEvent port="in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
```
```{code-block} xml
<OnEvent port="spikes-in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
```
````
`````
Expand Down Expand Up @@ -640,27 +640,27 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<Regime name="int" initial="true">
<TimeDerivative variable="v" value="(current + gleak * (vleak - v)) / capacitance"/>
<OnCondition test="v .gt. threshold">
<EventOut port="out"/>
<Transition regime="refr"/>
</OnCondition>
<OnEvent port="in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
</Regime>
```
```{code-block} xml
<Regime name="refr">
<OnEntry>
<StateAssignment variable="tin" value="t"/>
<StateAssignment variable="v" value="vreset"/>
</OnEntry>
<OnCondition test="t .gt. tin + refractoryPeriod">
<Transition regime="int"/>
</OnCondition>
</Regime>
<Regime name="int" initial="true">
<TimeDerivative variable="v" value="(current + gleak * (vleak - v)) / capacitance"/>
<OnCondition test="v .gt. threshold">
<EventOut port="out"/>
<Transition regime="refr"/>
</OnCondition>
<OnEvent port="in">
<StateAssignment variable="v" value="v + deltaV"/>
</OnEvent>
</Regime>
```
```{code-block} xml
<Regime name="refr">
<OnEntry>
<StateAssignment variable="tin" value="t"/>
<StateAssignment variable="v" value="vreset"/>
</OnEntry>
<OnCondition test="t .gt. tin + refractoryPeriod">
<Transition regime="int"/>
</OnCondition>
</Regime>
```
````
`````
Expand Down Expand Up @@ -697,10 +697,10 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<OnEntry>
<StateAssignment variable="tin" value="t"/>
<StateAssignment variable="v" value="vreset"/>
</OnEntry>
<OnEntry>
<StateAssignment variable="tin" value="t"/>
<StateAssignment variable="v" value="vreset"/>
</OnEntry>
```
````
`````
Expand Down
20 changes: 10 additions & 10 deletions source/Userdocs/LEMS_elements/Simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ Please file any issues or questions at the [issue tracker here](https://github.c
````{tab-item} Usage: XML
```{code-block} xml
<Simulation>
<DataDisplay title="title" dataRegion="xmin,xmax,ymin,ymax"/>
</Simulation>
<DataDisplay title="title" dataRegion="xmin,xmax,ymin,ymax"/>
</Simulation>
```
```{code-block} xml
<Simulation>
<Record quantity="quantity" timeScale="timeScale" scale="scale" color="color"/>
</Simulation>
<Record quantity="quantity" timeScale="timeScale" scale="scale" color="color"/>
</Simulation>
```
```{code-block} xml
<Simulation>
<DataWriter path="path" fileName="fileName"/>
</Simulation>
<DataWriter path="path" fileName="fileName"/>
</Simulation>
```
```{code-block} xml
<Simulation>
<Record quantity="quantity"/>
</Simulation>
<Record quantity="quantity"/>
</Simulation>
```
```{code-block} xml
<Simulation>
<Run component="target" variable="t" increment="step" total="length"/>
</Simulation>
<Run component="target" variable="t" increment="step" total="length"/>
</Simulation>
```
````
`````
Expand Down
Loading

0 comments on commit ae12932

Please sign in to comment.