Skip to content

Commit

Permalink
feat(ci): Support doxygen single line comments in style checker (endl…
Browse files Browse the repository at this point in the history
…ess-sky#10814)

Co-authored-by: tibetiroka <[email protected]>
  • Loading branch information
petervdmeer and tibetiroka authored Dec 1, 2024
1 parent ecd9741 commit 4f018d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
29 changes: 13 additions & 16 deletions source/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Preferences {
};

enum class DateFormat : int_fast8_t {
DMY = 0, // Day-first format. (Sat, 4 Oct 1941)
MDY, // Month-first format. (Sat, Oct 4, 1941)
YMD // All-numeric ISO 8601. (1941-10-04)
DMY = 0, ///< Day-first format. (Sat, 4 Oct 1941)
MDY, ///< Month-first format. (Sat, Oct 4, 1941)
YMD ///< All-numeric ISO 8601. (1941-10-04)
};

enum class OverlayState : int_fast8_t {
Expand Down Expand Up @@ -110,21 +110,18 @@ class Preferences {
static bool Has(const std::string &name);
static void Set(const std::string &name, bool on = true);

// Toggle the ammo usage preferences, cycling between "never," "frugally,"
// and "always."
/// Toggle the ammo usage preferences, cycling between "never," "frugally," and "always."
static void ToggleAmmoUsage();
static std::string AmmoUsage();

// Date format preferences.
/// Date format preferences.
static void ToggleDateFormat();
static DateFormat GetDateFormat();
static const std::string &DateFormatSetting();

// Scroll speed preference.
static int ScrollSpeed();
static void SetScrollSpeed(int speed);

// View zoom.
static double ViewZoom();
static bool ZoomViewIn();
static bool ZoomViewOut();
Expand All @@ -135,7 +132,7 @@ class Preferences {
static void ToggleScreenMode();
static const std::string &ScreenModeSetting();

// VSync setting, either "on", "off", or "adaptive".
/// VSync setting, either "on", "off", or "adaptive".
static bool ToggleVSync();
static VSync VSyncState();
static const std::string &VSyncSetting();
Expand All @@ -148,37 +145,37 @@ class Preferences {
static OverlayState StatusOverlaysState(OverlayType type);
static const std::string &StatusOverlaysSetting(OverlayType type);

// Auto aim setting, either "off", "always on", or "when firing".
/// Auto aim setting, either "off", "always on", or "when firing".
static void ToggleAutoAim();
static AutoAim GetAutoAim();
static const std::string &AutoAimSetting();

// Auto fire setting, either "off", "on", "guns only", or "turrets only".
/// Auto fire setting, either "off", "on", "guns only", or "turrets only".
static void ToggleAutoFire();
static AutoFire GetAutoFire();
static const std::string &AutoFireSetting();

// Background parallax setting, either "fast", "fancy", or "off".
/// Background parallax setting, either "fast", "fancy", or "off".
static void ToggleParallax();
static BackgroundParallax GetBackgroundParallax();
static const std::string &ParallaxSetting();

// Extended jump effects setting, either "off", "medium", or "heavy".
/// Extended jump effects setting, either "off", "medium", or "heavy".
static void ToggleExtendedJumpEffects();
static ExtendedJumpEffects GetExtendedJumpEffects();
static const std::string &ExtendedJumpEffectsSetting();

// Boarding target setting, either "proximity", "value" or "mixed".
/// Boarding target setting, either "proximity", "value" or "mixed".
static void ToggleBoarding();
static BoardingPriority GetBoardingPriority();
static const std::string &BoardingSetting();

// Flotsam setting, either "off", "on", "flagship only", or "escorts only".
/// Flotsam setting, either "off", "on", "flagship only", or "escorts only".
static void ToggleFlotsam();
static FlotsamCollection GetFlotsamCollection();
static const std::string &FlotsamSetting();

// Red alert siren and symbol
/// Red alert siren and symbol
static void ToggleAlert();
static AlertIndicator GetAlertIndicator();
static const std::string &AlertSetting();
Expand Down
11 changes: 7 additions & 4 deletions utils/check_code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
after_comment = re.compile("[^\\s#]")
whitespace_only = re.compile("^\\s*$")
whitespaces = re.compile("\\s+")
singleLineComment = re.compile("^//(/<?)?")

# List of "" and <> includes to be treated as the other type;
# that is, any listed "" include should be grouped with <> includes,
Expand Down Expand Up @@ -239,13 +240,15 @@ def sanitize(lines, skip_checks=False):
i += 1
start_index = i + 1
continue
if (not is_string) and first_two == "//":
commentMatch = re.search(singleLineComment, line[i:i + 4])
if (not is_string and commentMatch):
segments.append(line[start_index:i].rstrip())
if not skip_checks:
cLen = commentMatch.end()
# Checking for space after comment
if len(line) > i + 2:
if re.search(after_comment, line[i + 2:i + 3]):
errors.append(Error(line[i:i + 3], line_count,
if len(line) > (i + cLen):
if re.search(after_comment, line[i + cLen:i + cLen + 1]):
errors.append(Error(line[i:i + cLen + 1], line_count,
"missing space after beginning of single-line comment"))
break
elif (not is_string) and first_two == "/*":
Expand Down

0 comments on commit 4f018d5

Please sign in to comment.