Skip to content

Commit

Permalink
linting fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
apple1417 committed Dec 21, 2024
1 parent 2169012 commit d7347b7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions text_mod_loader/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ but to summarize, simply add a few tags to the first comment block at the top of

Text Mod Loader supports the following tags.

| Tag Name | Multiple | Intepretation |
| Tag Name | Multiple | Interpretation |
| :--------------- | :------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `@author` | Allowed | The mod's author(s), all joined into a list, replacing `TextModLoader`. |
| `@description` | Allowed | Joined in the order encountered to create the mod's description. A tag with an empty value (after stripping whitespace) joins surrounding values with a newline, all other pairs are joined using a space. |
Expand Down Expand Up @@ -51,4 +51,4 @@ Text Mod Loader supports the following tags.
- Forced all mod info to be reloaded whenever you update TML.

## Text Mod Loader v1.0
- Inital Release.
- Initial Release.
2 changes: 1 addition & 1 deletion text_mod_loader/blimp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

# This file is just a helper to let you run the BLIMP tag test suite against the file parser
# It should be run in a regular intepreter, it (obviously) won't do anything from inside the game
# It should be run in a regular interpreter, it (obviously) won't do anything from inside the game
# https://github.com/apple1417/blcmm-parsing/tree/master/blimp#tests
if __name__ == "__main__":
import json
Expand Down
14 changes: 7 additions & 7 deletions text_mod_loader/file_parser/blcm_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ void extract_description(pugi::xml_document& doc, ParseResult& parse_result) {

static const constexpr CaseInsensitiveStringView comment = "comment";
if (child_name == comment) {
auto comment = child.child_value();
if (is_command(comment)) {
auto value = child.child_value();
if (is_command(value)) {
// This comment was really holding a command, the description's over
break;
}
parse_result.add_comment(comment);
parse_result.add_comment(value);
continue;
}

Expand All @@ -56,12 +56,12 @@ void extract_description(pugi::xml_document& doc, ParseResult& parse_result) {

for (auto grandchild : child) {
const std::string_view grandchild_name = grandchild.name();
if (grandchild_name == "comment") {
auto comment = grandchild.child_value();
if (is_command(comment)) {
if (grandchild_name == comment) {
auto value = grandchild.child_value();
if (is_command(value)) {
break;
}
parse_result.add_comment(comment);
parse_result.add_comment(value);
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions text_mod_loader/file_parser/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pybind11::error_already_set file_not_found(const std::filesystem::path& filename
*/
void look_for_spark_service(std::istream& input, ParseResult& parse_result) {
for (std::string line; std::getline(input, line);) {
// Aproximately matching the regex:
// /\s+set\s+Transient.SparkServiceConfiguration_\d+\s+(keys|values)/i
// Approximately matching the regex:
// /\s+set\s+Transient.SparkServiceConfiguration_(\d+)\s+(keys|values)/i

const constexpr CaseInsensitiveStringView set = "set";
const constexpr CaseInsensitiveStringView transient =
Expand Down
12 changes: 11 additions & 1 deletion text_mod_loader/file_parser/parse_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@

namespace tml {

struct ParseResult {
// By default, pybind tries to compile with visibility hidden
// If we have default visibility in a type holding pybind objects as members, this may cause a
// warning, since our type has greater visibility than it's members
// This macro sets the right visibility
#if defined(__MINGW32__)
#define PY_OBJECT_VISIBILITY __attribute__((visibility("hidden")))
#else
#define PY_OBJECT_VISIBILITY
#endif

struct PY_OBJECT_VISIBILITY ParseResult {
// Unordered map doesn't like working with python strings, have to store tags as a python dict
py::dict blimp_tags;
std::vector<py::str> untagged_lines;
Expand Down
2 changes: 1 addition & 1 deletion text_mod_loader/hotfixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def mark_hotfixes_used() -> None:

def is_hotfix_service(idx: int) -> bool:
"""
Checks if the given Spark Service index corosponds to the hotfix service.
Checks if the given Spark Service index corresponds to the hotfix service.
Args:
idx: The Spark Service index to check.
Expand Down
4 changes: 2 additions & 2 deletions text_mod_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def join_lines_markdown_like(lines: Iterable[str]) -> str:
"""
Joins a list of lines similarly to how markdown does it.
Adjacent lines get space seperated, you need an entirely empty line to add a newline.
Adjacent lines get space separated, you need an entirely empty line to add a newline.
Args:
lines: The lines to join.
Expand Down Expand Up @@ -139,7 +139,7 @@ def load_mod_info(path: Path) -> ModInfo:
if (description_list := parse_result.blimp_tags.get("@description")) is not None:
description = join_lines_markdown_like(description_list)
else:
# If there's no explict description tags, extract it from the untagged lines instead
# If there's no explicit description tags, extract it from the untagged lines instead
strip_chars = find_edge_characters(parse_result.untagged_lines)
description = join_lines_markdown_like(
line.strip(strip_chars) for line in parse_result.untagged_lines
Expand Down

0 comments on commit d7347b7

Please sign in to comment.