User Rating 0.0
Total Usage 0 times
4D Source Code
DocBlock Output
Is this tool helpful?

Your feedback helps us improve.

About

4D (4th Dimension) methods use a proprietary commenting style and type declaration syntax (C_TEXT, C_LONGINT, C_OBJECT) that no standard documentation generator understands. If your codebase lacks machine-readable DocBlocks, automated API docs become impossible, onboarding slows, and refactoring turns dangerous. This converter parses 4D parameter declarations ($1$n), return values ($0), and inline comments, then emits compliant /** … */ DocBlock output with @param, @returns, and @description tags. It handles 15 native 4D types and preserves comment context.

The tool assumes one method per input block. Multi-method files should be split before conversion. Nested C_* declarations inside conditionals are extracted but flagged as conditional parameters. Edge case: unnamed parameters (bare $1 without a preceding C_* line) are typed as unknown.

4d docblock jsdoc code-documentation comment-converter 4d-language code-formatter

Formulas

The converter applies a deterministic state-machine pass over each line of 4D source code. The core transformation rule maps 4D type declarations to DocBlock parameter tags:

C_TYPE($n) @param {mappedType} $n description

where C_TYPE is any 4D type keyword, $n is the parameter index (1N), and mappedType is resolved from the type mapping table. Return values follow:

C_TYPE($0) @returns {mappedType} description

Leading comment lines (// prefix) preceding any C_* declaration are collected into the @description field. The regex pattern for type extraction is:

match(/^\s*C_(\w+)\s*\((.+)\)/i)

where capture group 1 yields the type name and group 2 yields the comma-separated variable list. Array declarations use a parallel pattern:

match(/^\s*ARRAY\s+(\w+)\s*\((.+)\)/i)

Reference Data

4D Type DeclarationDocBlock TypeDescriptionDefault Value
C_TEXTstringUnicode text string""
C_LONGINTnumber32-bit signed integer (−231 to 2311)0
C_REALnumber64-bit IEEE 754 float0.0
C_BOOLEANbooleanTrue/False flagFALSE
C_POINTERPointerReference to any 4D objectNULL
C_OBJECTObjectJSON-compatible objectNULL
C_COLLECTIONCollectionOrdered array of valuesNULL
C_DATEDateCalendar date (no time)00/00/00
C_TIMETimeDuration in seconds from midnight00:00:00
C_BLOBBlobBinary large objectNULL
C_PICTUREPictureImage data containerNULL
C_VARIANT*Any type (resolved at runtime)undefined
C_INTEGERnumber16-bit signed integer (legacy)0
C_COMPnumber64-bit integer (composite)0
ARRAY TEXTstring[]Array of text values[]
ARRAY LONGINTnumber[]Array of 32-bit integers[]
ARRAY REALnumber[]Array of floats[]
ARRAY BOOLEANboolean[]Array of booleans[]
ARRAY OBJECTObject[]Array of objects[]
ARRAY POINTERPointer[]Array of pointers[]
ARRAY DATEDate[]Array of dates[]
ARRAY PICTUREPicture[]Array of images[]

Frequently Asked Questions

If a parameter variable like $1 appears in method body code but has no preceding C_TEXT, C_LONGINT, or other type declaration, the converter assigns the type * (any/unknown) in the DocBlock @param tag and appends a warning comment. This ensures the DocBlock is still structurally valid while flagging incomplete type information.
Yes. Lines beginning with // that appear before the first C_* declaration are concatenated into the @description field. Inline comments on the same line as a C_* declaration (after the closing parenthesis) are extracted and used as the parameter description in the corresponding @param tag. Block comments (/* ... */) are treated as description text.
4D allows declaring multiple variables in a single C_TEXT($1;$2;$3) statement using semicolons as separators. The converter splits on both ; and , delimiters, generating a separate @param entry for each variable. All share the same mapped type. Individual descriptions default to the parameter name unless an inline comment provides context.
Yes. Declarations like ARRAY TEXT($myArr;0) are parsed with a dedicated regex. The type maps to the array equivalent (e.g., string[]). The second argument (the size initializer, typically 0) is ignored in the DocBlock output since it is a runtime detail, not a type property.
4D uses $ prefix for local variables, <> for interprocess, and no prefix for process variables. The converter only generates @param tags for $0 through $n parameters. Process and interprocess variable declarations (C_TEXT(vMyVar) or C_TEXT(<>vShared)) are documented as internal variables using an @var tag instead.
The output follows JSDoc 3 conventions: /** */ delimiters, @param {type} name - description format, and @returns {type} description. This format is recognized by most documentation generators including JSDoc, TypeDoc, and Doxygen (with JSDoc filter). It is also parseable by IDEs such as VS Code for inline tooltip documentation.