Skip to content

Commit

Permalink
Merge pull request #401 from kdayday/md_formatter
Browse files Browse the repository at this point in the history
Add markdown files to formatter
  • Loading branch information
jd-lara authored Oct 1, 2024
2 parents be8eb50 + 2c65c3f commit 768438a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
7 changes: 5 additions & 2 deletions docs/src/dev_guide/auto_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ Or
directory.

```julia
InfrastructureSystems.generate_structs("./src/descriptors/power_system_structs.json", "./src/models/generated")
InfrastructureSystems.generate_structs(
"./src/descriptors/power_system_structs.json",
"./src/models/generated",
)
```

## Struct Descriptor Rules
Expand All @@ -52,7 +55,7 @@ Optional fields for each struct member:
- `exclude_setter`: Do not generate a setter function for this field.
- `internal_default`: Set to true for non-user-facing fields like `InfrastructureSystemsInternal` that have default values.
- `needs_conversion`: Set to true if the getter and setter function needs to apply unit conversion. The type must implement

+ `get_value(::InfrastructureSystemsComponent, ::Type)` and
+ `set_value(::InfrastructureSystemsComponent, ::Type)`
for this combination of component type and member type.
Expand Down
8 changes: 4 additions & 4 deletions docs/src/dev_guide/components_and_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ get_ext(c::MyComponent) = InfrastructureSystems.get_ext(c.ext)
clear_ext!(c::MyComponent) = InfrastructureSystems.clear_ext(c.ext)
```

2. Implement this function with `true` or `false` depending on whether your component type
will support time series data. The default method returns `false`.
2. Implement this function with `true` or `false` depending on whether your component type
will support time series data. The default method returns `false`.

```julia
supports_time_series(::MyComponent) = true
```

3. Implement this function with `true` or `false` depending on whether your component type
will support supplemental attributes. The default method returns `true`.
3. Implement this function with `true` or `false` depending on whether your component type
will support supplemental attributes. The default method returns `true`.

```julia
supports_supplemental_attributes(::MyComponent) = true
Expand Down
12 changes: 6 additions & 6 deletions docs/src/dev_guide/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ preferences (console and/or file, levels, etc.).
**Example**: Global logger configuration

```julia
logger = configure_logging(; filename="log.txt")
logger = configure_logging(; filename = "log.txt")
@info "hello world"
flush(logger)
@error "some error"
Expand Down Expand Up @@ -77,7 +77,7 @@ group in two ways:
2. Change the logger dynamically from with Julia. Here is an example:

```julia
logger = configure_logging(console_level=Logging.Debug)
logger = configure_logging(; console_level = Logging.Debug)
InfrastructureSystems.set_group_level!(
logger,
InfrastructureSystems.LOG_GROUP_TIME_SERIES,
Expand Down Expand Up @@ -150,7 +150,7 @@ The standard Logging module in Julia provides a method to suppress messages.
Tag the log message with maxlog = X.

```julia
for i in range(1, length=100)
for i in range(1; length = 100)
@error "something happened" i maxlog = 2
end
```
Expand All @@ -165,7 +165,7 @@ every five seconds. It will log how many log messages were suppressed on the
first message that gets logged after a timeout.

```julia
for i in range(1, length=100)
for i in range(1; length = 100)
@error "something happened" i maxlog = 2 _suppression_period = 5
sleep(0.5)
end
Expand All @@ -177,7 +177,7 @@ By default a `MultiLogger` creates a `LogEventTracker` that keeps counts of all
messages. Call `report_log_summary` after execution.

```julia
logger = configure_logging(; filename="log.txt")
logger = configure_logging(; filename = "log.txt")
@info "hello world"

# Include a summary in the log file.
Expand All @@ -188,7 +188,7 @@ close(logger)
The output of the logger can be explored in the REPL:

```julia
for i in range(1, length=100)
for i in range(1; length = 100)
@info "hello" maxlog = 2
@warn "beware" maxlog = 2
end
Expand Down
2 changes: 1 addition & 1 deletion docs/src/dev_guide/recorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ of that data to figure out what went wrong.
`RecorderEventCommon` in each struct.

2. Call [`InfrastructureSystems.register_recorder!`](@ref) with arguments `recorder-name` for each recorder object you want to create.

+ Depending on how often your code create events you may want to make this
conditional. You may only need it for debug runs.
+ PowerSimulations creates one recorder for simulation step and stage
Expand Down
4 changes: 2 additions & 2 deletions docs/src/dev_guide/time_series.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ deserialize the system.
- Time series data can optionally be stored fully in memory. Refer to the [`InfrastructureSystems.SystemData`](@ref) documentation.
- `InfrastructureSystems.jl` creates HDF5 files on the tmp filesystem by default, using the location obtained from `tempdir()`. This can be changed if the time series data is larger than the amount of tmp space available. Refer to the [`InfrastructureSystems.SystemData`](@ref) link above.
- By default, the call to `add_time_series!` will open the .h5 file, write the data to the file,
and close the file. Opening and closing the file has overhead. If you will add thousands of time
series arrays, consider using `open_time_series_store!` to add all the arrays with one file handle.
and close the file. Opening and closing the file has overhead. If you will add thousands of time
series arrays, consider using `open_time_series_store!` to add all the arrays with one file handle.

## Instructions

Expand Down
7 changes: 5 additions & 2 deletions scripts/formatter/formatter_code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Pkg.update()

using JuliaFormatter

main_paths = ["./src", "./test"]
main_paths = ["./src", "./test", "./docs/src"]
for main_path in main_paths
for (root, dir, files) in walkdir(main_path)
for f in files
@show file_path = abspath(root, f)
!occursin(".jl", f) && continue
!((occursin(".jl", f) || occursin(".md", f))) && continue
format(file_path;
whitespace_ops_in_indices = true,
remove_extra_newlines = true,
Expand All @@ -20,6 +20,9 @@ for main_path in main_paths
conditional_to_if = true,
join_lines_based_on_source = true,
separate_kwargs_with_semicolon = true,
format_markdown = true,
# Brackets in code blocks cause formatter to fail, ignore for now
ignore = ["style.md", "index.md", "tests.md"],

# always_use_return = true. # Disabled since it throws a lot of false positives
)
Expand Down

0 comments on commit 768438a

Please sign in to comment.