From fd6ac498b007714be1fb48d6debc26a55aaff67b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2025 00:18:39 +0000 Subject: [PATCH] Cleanup: spelling in comments, strings (make check_spelling_*) Also replace some triple-quoted non-doc-string strings with commented blocks in examples. --- doc/blender_file_format/BlendFileReader.py | 4 ++-- .../examples/bpy.app.translations.py | 2 +- .../examples/bpy.types.FileHandler.1.py | 24 +++++++++---------- doc/python_api/examples/bpy.types.UIList.2.py | 8 +++---- doc/python_api/sphinx_doc_gen.py | 2 +- intern/cycles/bvh/split.cpp | 2 +- .../blenkernel/intern/lib_query_test.cc | 2 +- source/blender/blenkernel/intern/node.cc | 2 +- .../blenlib/intern/memory_cache_file_load.cc | 2 +- .../intern/grease_pencil_lineart.cc | 2 +- .../gpu/glsl_preprocess/glsl_preprocess.hh | 2 +- source/blender/makesdna/DNA_ID_enums.h | 7 +++--- .../nodes/node_composite_map_range.cc | 2 +- tools/check_source/check_licenses.py | 2 +- tools/check_source/check_spelling_config.py | 2 ++ tools/utils_maintenance/c_sort_blocks.py | 16 ++++++++----- tools/utils_maintenance/code_clean.py | 2 +- 17 files changed, 44 insertions(+), 39 deletions(-) diff --git a/doc/blender_file_format/BlendFileReader.py b/doc/blender_file_format/BlendFileReader.py index 7a6c68a82d4..d9eb808be38 100644 --- a/doc/blender_file_format/BlendFileReader.py +++ b/doc/blender_file_format/BlendFileReader.py @@ -93,7 +93,7 @@ def openBlendFile(filename): def Align(handle): ''' - Aligns the filehandle on 4 bytes + Aligns the file-handle on 4 bytes ''' offset = handle.tell() trim = offset % 4 @@ -107,7 +107,7 @@ def Align(handle): class BlendFile: ''' - Reads a blend-file and store the header, all the file-blocks, and catalogue + Reads a blend-file and store the header, all the file-blocks, and catalog structs found in the DNA file-block - BlendFile.Header (BlendFileHeader instance) diff --git a/doc/python_api/examples/bpy.app.translations.py b/doc/python_api/examples/bpy.app.translations.py index 62b4217e1ba..9e672fb0cfd 100644 --- a/doc/python_api/examples/bpy.app.translations.py +++ b/doc/python_api/examples/bpy.app.translations.py @@ -12,7 +12,7 @@ Introduction To add translations to your Python script, you must define a dictionary formatted like that: ``{locale: {msg_key: msg_translation, ...}, ...}`` where: -- locale is either a lang iso code (e.g. ``fr``), a lang+country code (e.g. ``pt_BR``), +- locale is either a lang ISO code (e.g. ``fr``), a lang+country code (e.g. ``pt_BR``), a lang+variant code (e.g. ``sr@latin``), or a full code (e.g. ``uz_UZ@cyrilic``). - msg_key is a tuple (context, org message) - use, as much as possible, the predefined :const:`contexts`. - msg_translation is the translated message in given language! diff --git a/doc/python_api/examples/bpy.types.FileHandler.1.py b/doc/python_api/examples/bpy.types.FileHandler.1.py index 1c9620715e4..8a3c0c8040f 100644 --- a/doc/python_api/examples/bpy.types.FileHandler.1.py +++ b/doc/python_api/examples/bpy.types.FileHandler.1.py @@ -26,14 +26,14 @@ import bpy class CurveTextImport(bpy.types.Operator): - """ Test importer that creates a text object from a .txt file """ + """ + Test importer that creates a text object from a text file. + """ bl_idname = "curve.text_import" bl_label = "Import a text file as text object" - """ - This Operator supports import one .txt file at the time, we need the - following filepath property that the file handler will use to set file path data. - """ + # This Operator supports import one `.txt` file at the time, we need the + # following file-path property that the file handler will use to set file path data. filepath: bpy.props.StringProperty(subtype='FILE_PATH', options={'SKIP_SAVE'}) @classmethod @@ -41,7 +41,7 @@ class CurveTextImport(bpy.types.Operator): return (context.area and context.area.type == "VIEW_3D") def execute(self, context): - """ Calls to this Operator can set unfiltered filepaths, ensure the file extension is .txt. """ + # Calls to this Operator can set unfiltered file-paths, ensure the file extension is `.txt`. if not self.filepath or not self.filepath.endswith(".txt"): return {'CANCELLED'} @@ -52,13 +52,11 @@ class CurveTextImport(bpy.types.Operator): bpy.context.scene.collection.objects.link(text_object) return {'FINISHED'} - """ - By default the file handler invokes the operator with the filepath property set. - In this example if this property is set the operator is executed, if not the - file select window is invoked. - This depends on setting ``options={'SKIP_SAVE'}`` to the property options to avoid - to reuse filepath data between operator calls. - """ + # By default the file handler invokes the operator with the file-path property set. + # In this example if this property is set the operator is executed, if not the + # file select window is invoked. + # This depends on setting `options={'SKIP_SAVE'}` to the property options to avoid + # to reuse file-path data between operator calls. def invoke(self, context, event): if self.filepath: diff --git a/doc/python_api/examples/bpy.types.UIList.2.py b/doc/python_api/examples/bpy.types.UIList.2.py index 4e3dd0f571f..ca2d4d65508 100644 --- a/doc/python_api/examples/bpy.types.UIList.2.py +++ b/doc/python_api/examples/bpy.types.UIList.2.py @@ -108,7 +108,7 @@ class MESH_UL_vgroups_slow(bpy.types.UIList): def filter_items_empty_vgroups(self, context, vgroups): # This helper function checks vgroups to find out whether they are empty, and what's their average weights. - # TODO: This should be RNA helper actually (a vgroup prop like "raw_data: ((vidx, vweight), etc.)"). + # TODO: This should be RNA helper actually (a vgroup prop like `"raw_data: ((vidx, vweight), etc.)"`). # Too slow for Python! obj_data = context.active_object.data ret = {vg.index: [True, 0.0] for vg in vgroups} @@ -131,7 +131,7 @@ class MESH_UL_vgroups_slow(bpy.types.UIList): ret[vg.group][0] = False ret[vg.group][1] += vg.weight * fact elif hasattr(obj_data, "points"): # Lattice data - # XXX no access to lattice editdata? + # XXX: no access to lattice edit-data? fact = 1 / len(obj_data.points) for v in obj_data.points: for vg in v.groups: @@ -142,11 +142,11 @@ class MESH_UL_vgroups_slow(bpy.types.UIList): def filter_items(self, context, data, propname): # This function gets the collection property (as the usual tuple (data, propname)), and must return two lists: # * The first one is for filtering, it must contain 32bit integers were self.bitflag_filter_item marks the - # matching item as filtered (i.e. to be shown). The upper 16 bits (including self.bitflag_filter_item) are + # matching item as filtered (i.e. to be shown). The upper 16 bits (including `self.bitflag_filter_item`) are # reserved for internal use, the lower 16 bits are free for custom use. Here we use the first bit to mark # VGROUP_EMPTY. # * The second one is for reordering, it must return a list containing the new indices of the items (which - # gives us a mapping org_idx -> new_idx). + # gives us a mapping `org_idx -> new_idx`). # Please note that the default UI_UL_list defines helper functions for common tasks (see its doc for more info). # If you do not make filtering and/or ordering, return empty list(s) (this will be more efficient than # returning full lists doing nothing!). diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index d948a12e659..ca2ddfd30fc 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -2628,7 +2628,7 @@ def main(): BPY_LOGGER.debug(" %s.py", f) BPY_LOGGER.debug(" %d total\n", len(EXAMPLE_SET_UNUSED)) - # Eventually, build the html docs. + # Eventually, build the HTML docs. if ARGS.sphinx_build: import subprocess subprocess.call(SPHINX_BUILD) diff --git a/intern/cycles/bvh/split.cpp b/intern/cycles/bvh/split.cpp index b0b16ea242e..4a8c9369a4b 100644 --- a/intern/cycles/bvh/split.cpp +++ b/intern/cycles/bvh/split.cpp @@ -267,7 +267,7 @@ void BVHSpatialSplit::split(BVHBuild *builder, /* Duplicate or unsplit references intersecting both sides. * * Duplication happens into a temporary pre-allocated vector in order to - * reduce number of memmove() calls happening in vector.insert(). + * reduce number of `memmove()` calls happening in `vector.insert()`. */ vector &new_refs = storage_->new_references; new_refs.clear(); diff --git a/source/blender/blenkernel/intern/lib_query_test.cc b/source/blender/blenkernel/intern/lib_query_test.cc index e4daa16b273..9aee7a842a7 100644 --- a/source/blender/blenkernel/intern/lib_query_test.cc +++ b/source/blender/blenkernel/intern/lib_query_test.cc @@ -298,7 +298,7 @@ TEST_F(LibQueryTest, libquery_subdata) EXPECT_EQ(context.scene->id.us, 0); EXPECT_EQ(context.object->id.us, 0); - /* The material's nodetre input node IDProperty uses the target object. */ + /* The material's node-tree input node IDProperty uses the target object. */ EXPECT_EQ(context.target->id.us, 42); EXPECT_EQ(context.mesh->id.us, 0); } diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 7d277d20364..6e9742206d3 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1007,7 +1007,7 @@ static void write_compositor_legacy_properties(bNodeTree &node_tree) if (node->type_legacy == CMP_NODE_BILATERALBLUR) { NodeBilateralBlurData *storage = static_cast(node->storage); - /* The size input is ceil(iterations + sigma_space). */ + /* The size input is `ceil(iterations + sigma_space)`. */ const bNodeSocket *size_input = blender::bke::node_find_socket(*node, SOCK_IN, "Size"); storage->iter = size_input->default_value_typed()->value - 1; storage->sigma_space = 1.0f; diff --git a/source/blender/blenlib/intern/memory_cache_file_load.cc b/source/blender/blenlib/intern/memory_cache_file_load.cc index 4c651b7e368..ba6c1801b3a 100644 --- a/source/blender/blenlib/intern/memory_cache_file_load.cc +++ b/source/blender/blenlib/intern/memory_cache_file_load.cc @@ -116,7 +116,7 @@ static void invalidate_outdated_caches_if_necessary(const Span fi /* Isolate because a mutex is locked. */ threading::isolate_task([&]() { /* Invalidation is done while the mutex is locked so that other threads won't see the old - * cached value anymore after we've detected that it's oudated. */ + * cached value anymore after we've detected that it's outdated. */ memory_cache::remove_if([&](const GenericKey &other_key) { if (const auto *other_key_typed = dynamic_cast(&other_key)) { const Span other_key_paths = other_key_typed->file_paths(); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_lineart.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_lineart.cc index 01578edbdbe..68409128d5d 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_lineart.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_lineart.cc @@ -194,7 +194,7 @@ static bool bake_strokes(Object *ob, MOD_lineart_destroy_render_data_v3(lmd); } else { - /* Use the cacued result, *lc is already valid. */ + /* Use the cached result, `*lc` is already valid. */ local_lc = *lc; } MOD_lineart_chain_clear_picked_flag(local_lc); diff --git a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh index 846fe7ae939..6da219a4e22 100644 --- a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh +++ b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh @@ -774,7 +774,7 @@ class Preprocessor { /* To be run before `argument_decorator_macro_injection()`. */ std::string argument_reference_mutation(std::string &str) { - /* Next two regexes are expensive. Check if they are needed at all. */ + /* Next two REGEX checks are expensive. Check if they are needed at all. */ bool valid_match = false; reference_search(str, [&](int parenthesis_depth, int bracket_depth, char &c) { /* Check if inside a function signature. diff --git a/source/blender/makesdna/DNA_ID_enums.h b/source/blender/makesdna/DNA_ID_enums.h index 73f405180ab..52ccbdfe17f 100644 --- a/source/blender/makesdna/DNA_ID_enums.h +++ b/source/blender/makesdna/DNA_ID_enums.h @@ -112,9 +112,10 @@ typedef enum eIDPropertyFlag { * Written to #BHead.code (for file IO) * and the first 2 bytes of #ID.name (for runtime checks, see #GS macro). * - * These types should also be available on their corresponding DNA struct. It must be a static - * constexpr data member so that it can be used in compile-time expressions and does not take up - * space in the struct. This is used by e.g. #BKE_id_new_nomain for improved type safety. + * These types should also be available on their corresponding DNA struct. + * It must be a static `constexpr` data member so that it can be used in + * compile-time expressions and does not take up space in the struct. + * This is used by e.g. #BKE_id_new_nomain for improved type safety. * * Update #ID_TYPE_IS_DEPRECATED() when deprecating types. */ diff --git a/source/blender/nodes/composite/nodes/node_composite_map_range.cc b/source/blender/nodes/composite/nodes/node_composite_map_range.cc index d08b35a8d47..af8ca24fc10 100644 --- a/source/blender/nodes/composite/nodes/node_composite_map_range.cc +++ b/source/blender/nodes/composite/nodes/node_composite_map_range.cc @@ -122,7 +122,7 @@ static float map_range(const float value, static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder) { static auto no_clamp_function = mf::build::SI5_SO( - "Map Range No CLamp", + "Map Range No Clamp", [](const float value, const float from_min, const float from_max, diff --git a/tools/check_source/check_licenses.py b/tools/check_source/check_licenses.py index 55a27fdea05..98debb9bfb3 100644 --- a/tools/check_source/check_licenses.py +++ b/tools/check_source/check_licenses.py @@ -510,7 +510,7 @@ def main() -> None: "./lib", # Needs manual handling as it mixes two licenses. "./intern/atomic", - # Practically an "extern" within an "intern" module, leave as-is. + # Practically an `./extern` within an `./intern` module, leave as-is. "./intern/itasc/kdl", # TODO: Files in these directories should be handled but the files have valid licenses. diff --git a/tools/check_source/check_spelling_config.py b/tools/check_source/check_spelling_config.py index 37345484192..9bdcb7c13a2 100644 --- a/tools/check_source/check_spelling_config.py +++ b/tools/check_source/check_spelling_config.py @@ -528,7 +528,9 @@ dict_custom = { "unsetting", "unshadowed", "unshared", + "unsharing", "unsharp", + "unshearing", "unspecialized", "unsqueezed", "unstretch", diff --git a/tools/utils_maintenance/c_sort_blocks.py b/tools/utils_maintenance/c_sort_blocks.py index 183eb2ac202..217a71cc508 100755 --- a/tools/utils_maintenance/c_sort_blocks.py +++ b/tools/utils_maintenance/c_sort_blocks.py @@ -34,6 +34,9 @@ SOURCE_EXT = ( def sort_struct_lists(fn: str, data_src: str) -> str | None: import re + # Disable for now. + use_datatoc_match = False + # eg: # struct Foo; re_match_struct = re.compile(r"struct\s+[A-Za-z_][A-Za-z_0-9]*\s*;") @@ -47,9 +50,10 @@ def sort_struct_lists(fn: str, data_src: str) -> str | None: re_match_enum = re.compile(r"enum\s+[A-Za-z_][A-Za-z_0-9]*\s*;") - # eg: - # extern char datatoc_splash_png[]; - # re_match_datatoc = re.compile(r"extern\s+(char)\s+datatoc_[A-Za-z_].*;") + if use_datatoc_match: + # eg: + # `extern char datatoc_splash_png[];` + re_match_datatoc = re.compile(r"extern\s+(char)\s+datatoc_[A-Za-z_].*;") lines = data_src.splitlines(keepends=True) @@ -62,9 +66,9 @@ def sort_struct_lists(fn: str, data_src: str) -> str | None: return 3 if re_match_enum.match(l): return 4 - # Disable for now. - # if re_match_datatoc.match(l): - # return 5 + if use_datatoc_match: + if re_match_datatoc.match(l): + return 5 return None i = 0 diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index 295824fff1b..b795f8bc4a6 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -1974,7 +1974,7 @@ def run_edits_on_directory( # needed for when arguments are referenced relatively os.chdir(build_dir) - # Weak, but we probably don't want to handle extern. + # Weak, but we probably don't want to handle `./extern/`. # this limit could be removed. source_paths = ( os.path.join("intern", "ghost"),