This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
make prepare- Install Ruby dependencies via Bundler (run first)make html- Build HTML tobuild/nxsl.htmlmake pdf- Build PDF tobuild/nxsl.pdfmake all- Build both formatsmake watch- Auto-rebuild on file changes (uses fswatch on macOS, inotifywait on Linux)EXTENDED=yes make html- Build with extended content flag
Entry point: index.adoc includes all major sections:
language-syntax.adoc- NXSL language referencefunctions.adoc→func-*.adoc→functions/<category>/*.adoc- Function docs organized by categoryclasses.adoc→classes/*.adoc- Class documentation (70+ classes)constants.adoc- Global constantsdeprecated.adoc→deprecated/*.adoc- Deprecated functions
Function categories (in func-*.adoc files):
func-math.adoc- Math package functionsfunc-string.adoc,func-time.adoc,func-objects.adoc,func-datacollection.adoc,func-alarms.adoc,func-events.adoc,func-misc.adoc,func-base64.adoc,func-crypto.adoc,func-files.adoc,func-net.adoc
Class inheritance: Many classes extend NetObj or DataCollectionTarget. Cross-references use <<class-name>> syntax.
Function template (functions/<category>/<name>.adoc):
[.nxsl-function]
[[func-category-name]]
== FunctionName()
FunctionName(param1, param2) => <<class-returntype>>::
Description paragraph. For multi-paragraph descriptions, use + continuation:
+
Additional paragraph text.
+
.Parameters
[cols="1,1,3" grid="none", frame="none"]
|===
|param1|Type|Description.
|param2|Type|Description.
|===
+
.Return
Return value description.
+
[.source]
....
// Example code
....Key formatting rules:
- Signature uses definition list format with
::at end - No blank line after
::- description starts immediately - Use
+between paragraphs within description - Use
+before.Parameters,.Return, and[.source]sections - Return types: primitives as plain text (
int,bool,string), objects as cross-references (<<class-node>>) - Examples use
[.source]with....delimiters (not[source,c]with----)
Class template (classes/<name>.adoc):
[.nxsl-class]
[[class-name]]
=== ClassName
Description. Extends <<class-parent>>.
==== Instance attributes
`attributeName => Type`::
Description.
==== Instance methods
`methodName(params) => ReturnType`::
Description with parameters table and examples.lib/stats.rb- Asciidoctor extension for analytics (CI only)netxms-theme.yml- PDF styling configurationGemfile- Ruby dependencies (asciidoctor 2.0.26, asciidoctor-pdf 2.3.24, coderay 1.1.3)
Return value semantics:
- Expression without semicolon → implicitly returns the expression's value
- Statement with semicolon but no
return→ returnsnull - Semicolons are NOT required in NXSL (contrary to C-like expectations)
Implicit main: Code outside functions is wrapped into $main() (note the $ prefix).
main() override behavior: If both explicit main() and top-level code exist, the top-level code is silently discarded - only main() executes.
Function argument counts:
trace(level, message)- exactly 2 args, use string concatenation:trace(3, "msg " .. value)println(...)- variadic, accepts multiple args:println("a", "b", "c")
Function argument mixing: Named arguments (e.g., arg3: "value") count toward positional parameter indices. In myFunc("first", arg3: "third", "second"), the named parameter arg3 occupies position 2, making $2 equal to "third". This can create confusing behavior when mixing argument styles.
Custom anchors: Add explicit [[anchor-name]] for sections that need cross-references. Don't rely on auto-generated anchors.
Operator documentation: For new operators in language-syntax.adoc, use the standard table format:
[cols="<33,<33,<33",options="header"]
|===
| Example| Name| Result
|`syntax`| Name| Description.
|===Multi-location feature docs: Document new language features in three places:
language-syntax.adoc- Full reference with examplesguide/getting-started.adoc- Beginner introduction in relevant sectionguide/working-with-netxms.adoc- Brief mention in Best Practices
Version markers (Python-style with colored left borders):
[.version-added]
Added in version 5.3
[.version-changed]
Changed in version 4.4.1: Description of change.
[.version-deprecated]
Deprecated in version 5.0. Use <<replacement>> instead.For inline short markers: [.version-added]#Added in version 5.1#
Use + continuation to attach version markers to description list items:
`methodName() => Type`::
Description text.
+
[.version-added]
Added in version 5.3Version marker styling evolution: Final design uses only colored italic text (no borders, no backgrounds) for minimal visual clutter. Initial attempts with borders and backgrounds proved too visually heavy. Color scheme: green (#2d6a2e) for added, amber (#856404) for changed, red (#721c24) for deprecated.
Version marker placement: Always place BEFORE descriptions for better visibility. For parameters in tables, place after the table closes but before the next section (.Return, .Example, etc.). Use format "Added in version X.X: parameter parameter" when noting specific parameters.
CSS spacing fix: Reset <p> margin to 0 inside version marker divs to prevent excessive spacing from AsciiDoc's default paragraph margins:
.version-added p,
.version-changed p,
.version-deprecated p {
margin: 0;
}- NetXMS source code is at
/Users/alk/Development/netxms/netxms-master - NXSL global function implementations:
src/libnxsl/functions.cpp, registered insrc/libnxsl/env.cpp - NXSL string method implementations:
src/libnxsl/string.cpp - To determine which version a feature was added in, find the commit and check which stable branch contains it:
git branch -a --contains <commit-hash>— branchstable-X.Ymeans version X.Y - YouTrack issue tracker (track.radensolutions.com) requires authentication — ask user for issue details if needed
- Global functions (e.g.,
LevenshteinDistance): separate file infunctions/<category>/orfunctions/, included viafunc-*.adoc - String methods (e.g.,
fuzzyEquals): inline inlanguage-syntax.adocunder the string methods section (alphabetically ordered) - Class attributes/methods: in
classes/<classname>.adoc
Problem-first structure: When explaining solutions (like global keyword), show the problem first to establish motivation:
- State default behavior
- Show failing example
- Explain the error
- Introduce solution
- Show working example
- Confirm success
This prevents reader confusion from examples that appear to contradict the opening statement.
Multi-option features: When documenting features with multiple approaches, use numbered methods with clear recommendations:
- Number each method explicitly (1, 2, 3...)
- Mark the recommended approach in the heading
- Provide "when to use this" guidance for each
- Add cautionary notes for confusing or edge-case patterns
- Present the standard/recommended approach first
Inline comments in examples: Use inline comments to explain non-obvious behavior, especially for edge cases:
// $2: third (named parameter arg3 occupies position 2)