Skip to content

Commit 1d665bb

Browse files
authored
introduce auto-formatting and init scripts (#2664)
* introduce auto formatting with clang-format * add init scripts * fix after format * fix
1 parent 3a0d6f5 commit 1d665bb

File tree

535 files changed

+50258
-57273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+50258
-57273
lines changed

.clang-format

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionDeclarations: false
12+
AlignFunctionPointers: false
13+
PadOperators: true
14+
AlignConsecutiveBitFields:
15+
Enabled: false
16+
AcrossEmptyLines: false
17+
AcrossComments: false
18+
AlignCompound: false
19+
AlignFunctionDeclarations: false
20+
AlignFunctionPointers: false
21+
PadOperators: false
22+
AlignConsecutiveDeclarations:
23+
Enabled: false
24+
AcrossEmptyLines: false
25+
AcrossComments: false
26+
AlignCompound: false
27+
AlignFunctionDeclarations: true
28+
AlignFunctionPointers: false
29+
PadOperators: false
30+
AlignConsecutiveMacros:
31+
Enabled: false
32+
AcrossEmptyLines: false
33+
AcrossComments: false
34+
AlignCompound: false
35+
AlignFunctionDeclarations: false
36+
AlignFunctionPointers: false
37+
PadOperators: false
38+
AlignConsecutiveShortCaseStatements:
39+
Enabled: false
40+
AcrossEmptyLines: false
41+
AcrossComments: false
42+
AlignCaseArrows: false
43+
AlignCaseColons: false
44+
AlignConsecutiveTableGenBreakingDAGArgColons:
45+
Enabled: false
46+
AcrossEmptyLines: false
47+
AcrossComments: false
48+
AlignCompound: false
49+
AlignFunctionDeclarations: false
50+
AlignFunctionPointers: false
51+
PadOperators: false
52+
AlignConsecutiveTableGenCondOperatorColons:
53+
Enabled: false
54+
AcrossEmptyLines: false
55+
AcrossComments: false
56+
AlignCompound: false
57+
AlignFunctionDeclarations: false
58+
AlignFunctionPointers: false
59+
PadOperators: false
60+
AlignConsecutiveTableGenDefinitionColons:
61+
Enabled: false
62+
AcrossEmptyLines: false
63+
AcrossComments: false
64+
AlignCompound: false
65+
AlignFunctionDeclarations: false
66+
AlignFunctionPointers: false
67+
PadOperators: false
68+
AlignEscapedNewlines: Right
69+
AlignOperands: Align
70+
AlignTrailingComments:
71+
Kind: Always
72+
OverEmptyLines: 0
73+
AllowAllArgumentsOnNextLine: true
74+
AllowAllParametersOfDeclarationOnNextLine: true
75+
AllowBreakBeforeNoexceptSpecifier: Never
76+
AllowShortBlocksOnASingleLine: Never
77+
AllowShortCaseExpressionOnASingleLine: true
78+
AllowShortCaseLabelsOnASingleLine: false
79+
AllowShortCompoundRequirementOnASingleLine: true
80+
AllowShortEnumsOnASingleLine: true
81+
AllowShortFunctionsOnASingleLine: All
82+
AllowShortIfStatementsOnASingleLine: Never
83+
AllowShortLambdasOnASingleLine: All
84+
AllowShortLoopsOnASingleLine: false
85+
AllowShortNamespacesOnASingleLine: false
86+
AlwaysBreakAfterDefinitionReturnType: None
87+
AlwaysBreakBeforeMultilineStrings: false
88+
AttributeMacros:
89+
- __capability
90+
BinPackArguments: true
91+
BinPackLongBracedList: true
92+
BinPackParameters: BinPack
93+
BitFieldColonSpacing: Both
94+
BracedInitializerIndentWidth: -1
95+
BraceWrapping:
96+
AfterCaseLabel: false
97+
AfterClass: false
98+
AfterControlStatement: Never
99+
AfterEnum: false
100+
AfterExternBlock: false
101+
AfterFunction: false
102+
AfterNamespace: false
103+
AfterObjCDeclaration: false
104+
AfterStruct: false
105+
AfterUnion: false
106+
BeforeCatch: false
107+
BeforeElse: false
108+
BeforeLambdaBody: false
109+
BeforeWhile: false
110+
IndentBraces: false
111+
SplitEmptyFunction: true
112+
SplitEmptyRecord: true
113+
SplitEmptyNamespace: true
114+
BreakAdjacentStringLiterals: true
115+
BreakAfterAttributes: Leave
116+
BreakAfterJavaFieldAnnotations: false
117+
BreakAfterReturnType: None
118+
BreakArrays: true
119+
BreakBeforeBinaryOperators: None
120+
BreakBeforeConceptDeclarations: Always
121+
BreakBeforeBraces: Attach
122+
BreakBeforeInlineASMColon: OnlyMultiline
123+
BreakBeforeTemplateCloser: false
124+
BreakBeforeTernaryOperators: true
125+
BreakBinaryOperations: Never
126+
BreakConstructorInitializers: BeforeColon
127+
BreakFunctionDefinitionParameters: false
128+
BreakInheritanceList: BeforeColon
129+
BreakStringLiterals: true
130+
BreakTemplateDeclarations: MultiLine
131+
ColumnLimit: 100
132+
CommentPragmas: '^ IWYU pragma:'
133+
CompactNamespaces: false
134+
ConstructorInitializerIndentWidth: 4
135+
ContinuationIndentWidth: 4
136+
Cpp11BracedListStyle: true
137+
DerivePointerAlignment: false
138+
DisableFormat: false
139+
EmptyLineAfterAccessModifier: Never
140+
EmptyLineBeforeAccessModifier: LogicalBlock
141+
EnumTrailingComma: Leave
142+
ExperimentalAutoDetectBinPacking: false
143+
FixNamespaceComments: true
144+
ForEachMacros:
145+
- foreach
146+
- Q_FOREACH
147+
- BOOST_FOREACH
148+
IfMacros:
149+
- KJ_IF_MAYBE
150+
IncludeBlocks: Preserve
151+
IncludeCategories:
152+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
153+
Priority: 2
154+
SortPriority: 0
155+
CaseSensitive: false
156+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
157+
Priority: 3
158+
SortPriority: 0
159+
CaseSensitive: false
160+
- Regex: '.*'
161+
Priority: 1
162+
SortPriority: 0
163+
CaseSensitive: false
164+
IncludeIsMainRegex: '(Test)?$'
165+
IncludeIsMainSourceRegex: ''
166+
IndentAccessModifiers: false
167+
IndentCaseBlocks: false
168+
IndentCaseLabels: false
169+
IndentExportBlock: true
170+
IndentExternBlock: AfterExternBlock
171+
IndentGotoLabels: true
172+
IndentPPDirectives: None
173+
IndentRequiresClause: true
174+
IndentWidth: 2
175+
IndentWrappedFunctionNames: false
176+
InsertBraces: false
177+
InsertNewlineAtEOF: false
178+
InsertTrailingCommas: None
179+
IntegerLiteralSeparator:
180+
Binary: 0
181+
BinaryMinDigits: 0
182+
Decimal: 0
183+
DecimalMinDigits: 0
184+
Hex: 0
185+
HexMinDigits: 0
186+
JavaScriptQuotes: Leave
187+
JavaScriptWrapImports: true
188+
KeepEmptyLines:
189+
AtEndOfFile: false
190+
AtStartOfBlock: true
191+
AtStartOfFile: true
192+
KeepFormFeed: false
193+
LambdaBodyIndentation: Signature
194+
LineEnding: DeriveLF
195+
MacroBlockBegin: ''
196+
MacroBlockEnd: ''
197+
MainIncludeChar: Quote
198+
MaxEmptyLinesToKeep: 1
199+
NamespaceIndentation: None
200+
ObjCBinPackProtocolList: Auto
201+
ObjCBlockIndentWidth: 2
202+
ObjCBreakBeforeNestedBlockParam: true
203+
ObjCSpaceAfterProperty: false
204+
ObjCSpaceBeforeProtocolList: true
205+
OneLineFormatOffRegex: ''
206+
PackConstructorInitializers: BinPack
207+
PenaltyBreakAssignment: 2
208+
PenaltyBreakBeforeFirstCallParameter: 19
209+
PenaltyBreakBeforeMemberAccess: 150
210+
PenaltyBreakComment: 300
211+
PenaltyBreakFirstLessLess: 120
212+
PenaltyBreakOpenParenthesis: 0
213+
PenaltyBreakScopeResolution: 500
214+
PenaltyBreakString: 1000
215+
PenaltyBreakTemplateDeclaration: 10
216+
PenaltyExcessCharacter: 1000000
217+
PenaltyIndentedWhitespace: 0
218+
PenaltyReturnTypeOnItsOwnLine: 60
219+
PointerAlignment: Right
220+
PPIndentWidth: -1
221+
QualifierAlignment: Leave
222+
ReferenceAlignment: Pointer
223+
ReflowComments: Always
224+
RemoveBracesLLVM: false
225+
RemoveEmptyLinesInUnwrappedLines: false
226+
RemoveParentheses: Leave
227+
RemoveSemicolon: false
228+
RequiresClausePosition: OwnLine
229+
RequiresExpressionIndentation: OuterScope
230+
SeparateDefinitionBlocks: Leave
231+
ShortNamespaceLines: 1
232+
SkipMacroDefinitionBody: false
233+
SortIncludes:
234+
Enabled: true
235+
IgnoreCase: false
236+
SortJavaStaticImport: Before
237+
SortUsingDeclarations: LexicographicNumeric
238+
SpaceAfterCStyleCast: false
239+
SpaceAfterLogicalNot: false
240+
SpaceAfterOperatorKeyword: false
241+
SpaceAfterTemplateKeyword: true
242+
SpaceAroundPointerQualifiers: Default
243+
SpaceBeforeAssignmentOperators: true
244+
SpaceBeforeCaseColon: false
245+
SpaceBeforeCpp11BracedList: false
246+
SpaceBeforeCtorInitializerColon: true
247+
SpaceBeforeInheritanceColon: true
248+
SpaceBeforeJsonColon: false
249+
SpaceBeforeParens: ControlStatements
250+
SpaceBeforeParensOptions:
251+
AfterControlStatements: true
252+
AfterForeachMacros: true
253+
AfterFunctionDefinitionName: false
254+
AfterFunctionDeclarationName: false
255+
AfterIfMacros: true
256+
AfterNot: false
257+
AfterOverloadedOperator: false
258+
AfterPlacementOperator: true
259+
AfterRequiresInClause: false
260+
AfterRequiresInExpression: false
261+
BeforeNonEmptyParentheses: false
262+
SpaceBeforeRangeBasedForLoopColon: true
263+
SpaceBeforeSquareBrackets: false
264+
SpaceInEmptyBlock: false
265+
SpacesBeforeTrailingComments: 1
266+
SpacesInAngles: Never
267+
SpacesInContainerLiterals: true
268+
SpacesInLineCommentPrefix:
269+
Minimum: 1
270+
Maximum: -1
271+
SpacesInParens: Never
272+
SpacesInParensOptions:
273+
ExceptDoubleParentheses: false
274+
InCStyleCasts: false
275+
InConditionalStatements: false
276+
InEmptyParentheses: false
277+
Other: false
278+
SpacesInSquareBrackets: false
279+
Standard: Latest
280+
StatementAttributeLikeMacros:
281+
- Q_EMIT
282+
StatementMacros:
283+
- Q_UNUSED
284+
- QT_REQUIRE_VERSION
285+
TableGenBreakInsideDAGArg: DontBreak
286+
TabWidth: 8
287+
UseTab: Never
288+
VerilogBreakBetweenInstancePorts: true
289+
WhitespaceSensitiveMacros:
290+
- BOOST_PP_STRINGIZE
291+
- CF_SWIFT_NAME
292+
- NS_SWIFT_NAME
293+
- PP_STRINGIZE
294+
- STRINGIZE
295+
WrapNamespaceBodyWithEmptyLines: Leave
296+
...
297+

AGENTS.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
# VNote Agent Development Guide
22

3+
## Setup
4+
5+
After cloning the repository, run the init script to set up your development environment:
6+
* **Linux/macOS**: `bash scripts/init.sh`
7+
* **Windows**: `scripts\init.cmd`
8+
39
## Build/Lint/Test Commands
410

511
* **Build**: `mkdir build && cd build && cmake .. && cmake --build . --config Release`
6-
* **Run Tests**: Build tests manually by enabling `add_subdirectory(tests)` in root CMakeLists.txt
7-
* **Run Single Test**: `cd build && ctest -R test_task` (after building tests)
12+
* **Debug Build**: `cmake .. -DCMAKE_BUILD_TYPE=Debug && cmake --build . --config Debug`
13+
* **Run Tests**: Uncomment `add_subdirectory(tests)` in root CMakeLists.txt, rebuild, then `ctest`
14+
* **Run Single Test**: `ctest -R test_task` (use test name pattern matching)
15+
* **Format Code**: Use clang-format with provided `.clang-format` (100 char line limit, 2-space indent)
816

917
## C++ Code Style Guidelines
1018

11-
* **Standards**: C++14, Qt 5/6 framework with MOC/UIC/RCC enabled
12-
* **Includes**: System includes first, then Qt includes, then local includes (see `main.cpp:1-29`)
13-
* **Namespaces**: Use `vnotex` namespace for all core classes
14-
* **Headers**: Use header guards (`#ifndef CLASSNAME_H`), forward declarations in headers
19+
* **Standards**: C++14, Qt 5/6 framework with CMAKE_AUTOMOC/AUTOUIC/AUTORCC enabled
20+
* **Includes**: Order: system includes, Qt includes, local includes (blank line between groups)
21+
* **Namespaces**: Use `vnotex` namespace for all core classes; `using namespace vnotex;` in .cpp files
22+
* **Headers**: Use header guards (`#ifndef CLASSNAME_H`), forward declarations preferred in headers
1523
* **Classes**: CamelCase, private inheritance for utility classes (Noncopyable pattern)
16-
* **Methods**: camelCase with getter prefixes (`getInst()`, `getThemeMgr()`)
17-
* **Members**: Prefix private members with `m_` (e.g., `m_jobj`)
18-
* **Singletons**: Use static instance pattern with `getInst()` method
19-
* **Qt Integration**: Use signals/slots, QObject inheritance, Q_OBJECT macro
20-
* **Memory**: Use Qt smart pointers (QScopedPointer, QSharedPointer)
21-
* **Config**: Access via ConfigMgr singleton, JSON-based hierarchical config
22-
* **Architecture**: Follow layered structure - core/ for logic, widgets/ for UI
23-
* **Error Handling**: Use Qt patterns and custom Exception classes
24+
* **Methods**: camelCase with getter prefixes (`getInst()`, `getThemeMgr()`), parameters prefixed with `p_`
25+
* **Members**: Prefix private members with `m_` (e.g., `m_jobj`, `m_themeMgr`)
26+
* **Singletons**: Use static instance pattern: `static Type &getInst() { static Type inst; return inst; }`
27+
* **Qt Integration**: Use signals/slots, QObject inheritance, Q_OBJECT macro for MOC
28+
* **Memory**: Use Qt smart pointers (QScopedPointer, QSharedPointer), not raw new/delete
29+
* **Config**: Access via ConfigMgr::getInst(), JSON-based hierarchical config system
30+
* **Architecture**: Layered structure - core/ for logic, widgets/ for UI, utils/ for helpers
31+
* **Error Handling**: Use custom Exception class with Exception::throwOne(), qCritical/qWarning/qInfo for logging
32+
* **Formatting**: 2-space indent, 100 char line limit, pointer alignment right (e.g., `int *ptr`)
2433

2534
## Architecture Notes
26-
* Core singleton: VNoteX coordinates all managers (ThemeMgr, TaskMgr, NotebookMgr, BufferMgr)
27-
* Refer to .github/copilot-instructions.md for complete architecture overview
35+
36+
* Core singleton VNoteX coordinates all managers (ThemeMgr, TaskMgr, NotebookMgr, BufferMgr)
37+
* ConfigMgr provides MainConfig, SessionConfig, CoreConfig, EditorConfig, WidgetConfig
38+
* Test framework uses Qt Test (QObject-based tests with initTestCase() and test methods)

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,26 @@ Latest stable builds could be found at the [latest release](https://github.com/v
3838

3939
Thank [users who donated to VNote](https://github.com/vnotex/vnote/wiki/Donate-List)!
4040

41+
## Development
42+
43+
After cloning the repository, run the initialization script to set up your development environment:
44+
45+
**Linux/macOS:**
46+
```bash
47+
bash scripts/init.sh
48+
```
49+
50+
**Windows:**
51+
```cmd
52+
scripts\init.cmd
53+
```
54+
55+
This script will:
56+
* Initialize and update all git submodules
57+
* Install pre-commit hooks for automatic code formatting with clang-format
58+
* Set up the vtextedit submodule pre-commit hook
59+
60+
For more development guidelines, see [AGENTS.md](AGENTS.md).
61+
4162
## License
4263
VNote is licensed under [GNU LGPLv3](https://opensource.org/licenses/LGPL-3.0). Code base of VNote could be used freely by VNoteX.

0 commit comments

Comments
 (0)