Skip to content

Commit 00a611f

Browse files
committed
[UPDATE] the doxygen in the code to be more verbose
1 parent 14804d3 commit 00a611f

File tree

13 files changed

+1417
-351
lines changed

13 files changed

+1417
-351
lines changed

vscode/asperheader/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file constants.ts
33
* @brief Global constants and configuration values for AsperHeader extension
44
* @author Henry Letellier
5-
* @version 1.0.0
5+
* @version 1.0.4
66
* @date 2025
77
*
88
* This module defines all global constants, configuration values, and default settings

vscode/asperheader/src/extension.ts

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
/**
2+
* @file extension.ts
3+
* @brief Main extension entry point for AsperHeader VS Code extension
4+
* @author Henry Letellier
5+
* @version 1.0.4
6+
* @date 2025
7+
*
8+
* This file serves as the primary activation point for the AsperHeader VS Code extension,
9+
* providing comprehensive file header management with ASCII art integration, multi-language
10+
* support, and automated documentation features. The extension orchestrates various
11+
* modules to deliver a cohesive development experience for file organization and
12+
* documentation standardization.
13+
*
14+
* Key responsibilities include:
15+
* - Extension lifecycle management (activation/deactivation)
16+
* - Command registration and routing
17+
* - Module initialization and dependency injection
18+
* - Workspace configuration and state management
19+
* - Document save event handling with header refresh
20+
*
21+
* The extension integrates multiple specialized modules:
22+
* - CommentGenerator: Automated header injection and refresh
23+
* - RandomLogo: ASCII art logo selection and display
24+
* - Darling: Easter egg functionality with character display
25+
* - Watermark: Author watermark management
26+
* - MorseTranslator: Text-to-Morse code conversion utilities
27+
* - Logger: Dual-channel logging system for development and user feedback
28+
*
29+
* @example Extension activation workflow:
30+
* ```typescript
31+
* // Extension activates automatically when VS Code loads
32+
* // Commands become available in Command Palette:
33+
* // - "AsperHeader: Hello World"
34+
* // - "AsperHeader: Say Hello World"
35+
* // - "AsperHeader: Inject Header"
36+
* // - "AsperHeader: Refresh Header"
37+
* // - "AsperHeader: Display Random Logo"
38+
*
39+
* // Headers auto-refresh on file save when configured
40+
* ```
41+
*/
42+
143
import * as path from "path";
244
import * as vscode from 'vscode';
345
import { moduleName } from './constants';
@@ -30,6 +72,16 @@ const WATERMARK: Watermark = new Watermark();
3072
const RANDOM_LOGO: RandomLogo = new RandomLogo();
3173

3274
// --- Helper functions ---
75+
76+
/**
77+
* @brief Extracts comprehensive file information from VS Code text editor
78+
* @param editor Active VS Code text editor instance
79+
* @return Object containing file path, name, extension, and language ID
80+
*
81+
* Analyzes the active editor's document to extract metadata used for
82+
* header generation and file processing. Essential for context-aware
83+
* operations across different file types and languages.
84+
*/
3385
function getFileInfo(editor: vscode.TextEditor) {
3486
const document = editor.document;
3587
const filePath = document.uri.fsPath;
@@ -43,14 +95,21 @@ function getFileInfo(editor: vscode.TextEditor) {
4395
// --- Command implementations ---
4496

4597
/**
46-
* Command: Hello World
98+
* @brief Displays a simple greeting message from the extension
99+
*
100+
* Basic command implementation showing informational notification
101+
* to verify extension functionality and user interaction.
47102
*/
48103
function helloWorldCommand() {
49104
vscode.window.showInformationMessage(getMessage("helloWorldGreetingsCommand", moduleName));
50105
}
51106

52107
/**
53-
* Command: Say Hello with file info
108+
* @brief Inserts greeting message with current file information
109+
*
110+
* Advanced hello command that analyzes the active editor and
111+
* inserts contextual information including file path, extension,
112+
* and language type. Demonstrates file analysis capabilities.
54113
*/
55114
async function sayHelloWorldCommand() {
56115
const editor = vscode.window.activeTextEditor;
@@ -69,7 +128,12 @@ async function sayHelloWorldCommand() {
69128
}
70129

71130
/**
72-
* Update checks to avoid concurrency during a save trigger
131+
* @brief Thread-safe document update handler for save events
132+
* @param document VS Code text document being saved
133+
*
134+
* Implements concurrency control to prevent multiple simultaneous
135+
* header updates during save operations. Uses WeakSet tracking
136+
* to ensure atomic updates and prevent corruption.
73137
*/
74138
async function updateSaveSafe(document: vscode.TextDocument) {
75139
if (updatingDocuments.has(document)) {
@@ -90,7 +154,11 @@ async function updateSaveSafe(document: vscode.TextDocument) {
90154
}
91155

92156
/**
93-
* Refresh the name of the cached workspace if any is activated
157+
* @brief Updates cached workspace name from VS Code workspace state
158+
*
159+
* Analyzes current workspace configuration to extract and cache
160+
* the workspace name for use in header generation. Handles both
161+
* workspace folders and legacy root path configurations.
94162
*/
95163
function refreshWorkspaceName() {
96164
let workspaceName: string | undefined;
@@ -107,9 +175,21 @@ function refreshWorkspaceName() {
107175
}
108176

109177
/**
110-
* Activate extension
178+
* @brief Main extension activation entry point
179+
* @param context VS Code extension context providing access to extension resources
180+
*
181+
* Orchestrates complete extension initialization including:
182+
* - Module dependency injection and configuration
183+
* - Asset path resolution for templates and resources
184+
* - Command registration for user interaction
185+
* - Event handler setup for document management
186+
* - Logger initialization with installation state
187+
*
188+
* Called automatically by VS Code when extension loads or
189+
* when activation events are triggered.
111190
*/
112191
export async function activate(context: vscode.ExtensionContext) {
192+
logger.updateInstallationState(context);
113193
logger.Gui.debug(`context.extensionPath: ${context.extensionPath}`);
114194
const jsonLanguagePath: string = path.join(
115195
context.extensionPath,
@@ -160,6 +240,10 @@ export async function activate(context: vscode.ExtensionContext) {
160240
}
161241

162242
/**
163-
* Deactivate extension
243+
* @brief Extension cleanup and deactivation handler
244+
*
245+
* Called when extension is deactivated, disabled, or VS Code closes.
246+
* Currently implements graceful shutdown without explicit cleanup
247+
* as modules handle their own resource management.
164248
*/
165249
export function deactivate() { }

vscode/asperheader/src/modules/commentGenerator.ts

Lines changed: 100 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,58 @@
11
/**
22
* @file commentGenerator.ts
3-
* @brief Comment generator module for creating file headers with logos and metadata
3+
* @brief Comprehensive comment and header generation system for AsperHeader extension
44
* @author Henry Letellier
5-
* @version 1.0.0
5+
* @version 1.0.4
66
* @date 2025
77
*
8-
* This module provides functionality to generate and manage file headers with
9-
* customizable logos, project information, and metadata. It supports multiple
10-
* comment styles and automatic header refresh on file save.
8+
* This module serves as the core engine for generating, injecting, and managing
9+
* file headers with customizable logos, project metadata, and timestamp tracking.
10+
* It provides intelligent comment style detection, multi-language support, and
11+
* seamless integration with the VS Code workspace environment.
12+
*
13+
* Architecture Overview:
14+
* - **CommentGenerator**: Main orchestrator class managing header lifecycle
15+
* - **Language Detection**: Automatic identification of file types and comment styles
16+
* - **Template System**: Flexible header templates with variable substitution
17+
* - **Logo Integration**: Dynamic logo selection from ASCII art collections
18+
* - **Metadata Management**: Creation date, modification tracking, and file properties
19+
* - **Configuration Integration**: Deep integration with {@link processConfiguration} system
20+
*
21+
* Key Dependencies:
22+
* - {@link LazyFileLoader}: Lazy loading of language configuration files
23+
* - {@link RandomLogo}: ASCII art logo selection and management
24+
* - {@link querier}: User interaction and input validation
25+
* - {@link logger}: Comprehensive logging and error reporting
26+
* - {@link processConfiguration}: Extension configuration and workspace settings
27+
*
28+
* Supported Features:
29+
* - Multi-line and single-line comment generation
30+
* - Language-specific comment syntax adaptation
31+
* - Automatic header refresh on file save
32+
* - Project name and workspace integration
33+
* - Telegraph-style protocol markers for structured headers
34+
* - Copyright and authorship attribution
35+
* - File description and purpose documentation
36+
*
37+
* Integration Points:
38+
* This module integrates with the extension's save event handlers, workspace
39+
* configuration system, and user interface components to provide seamless
40+
* header management throughout the development workflow.
41+
*
42+
* @example Basic header injection:
43+
* ```typescript
44+
* const generator = new CommentGenerator(lazyFileLoader);
45+
* generator.updateLogoInstanceRandomiser(randomLogo);
46+
* await generator.injectHeader(); // Injects header to active editor
47+
* ```
48+
*
49+
* @example Automatic refresh setup:
50+
* ```typescript
51+
* // In extension activation
52+
* vscode.workspace.onDidSaveTextDocument(async (document) => {
53+
* await generator.refreshHeader(document);
54+
* });
55+
* ```
1156
*/
1257

1358
import * as vscode from 'vscode';
@@ -36,19 +81,55 @@ interface CommentStyle {
3681
}
3782

3883
/**
39-
* @class CommentGenerator
40-
* @brief Main class responsible for generating and managing file headers
84+
* @class CommentGenerator
85+
* @brief Intelligent file header generation and management system
86+
*
87+
* The CommentGenerator class serves as the central orchestrator for all header-related
88+
* operations within the AsperHeader extension. It provides comprehensive functionality
89+
* for creating, updating, and maintaining file headers with rich metadata, ASCII art
90+
* logos, and language-appropriate comment formatting.
4191
*
42-
* This class handles the creation, injection, and updating of file headers with
43-
* project metadata, logos, creation/modification dates, and other customizable
44-
* information. It supports multiple programming languages and comment styles.
92+
* Core Responsibilities:
93+
* - **Header Lifecycle Management**: Creation, injection, refresh, and validation
94+
* - **Language Adaptation**: Automatic detection and appropriate comment style selection
95+
* - **Template Processing**: Dynamic variable substitution in header templates
96+
* - **Logo Integration**: Seamless integration with {@link RandomLogo} for ASCII art
97+
* - **Metadata Tracking**: Creation timestamps, modification dates, and file properties
98+
* - **User Interaction**: Prompting for missing information and configuration
4599
*
46-
* Key features:
47-
* - Automatic language detection and comment style selection
48-
* - Random logo generation from asset collections
49-
* - Header refresh on file save
50-
* - Metadata tracking (creation date, last modified, etc.)
51-
* - Multi-language support through configuration files
100+
* Architectural Features:
101+
* - **Lazy Loading**: Language configurations loaded on-demand for performance
102+
* - **Configuration Integration**: Deep coupling with {@link CodeConfig} settings
103+
* - **Error Resilience**: Comprehensive error handling and user feedback
104+
* - **Workspace Awareness**: Context-sensitive behavior based on workspace state
105+
* - **Multi-Language Support**: Extensible system supporting diverse programming languages
106+
*
107+
* Header Structure:
108+
* Generated headers follow a structured format including:
109+
* - Opening decoration and logo placement
110+
* - Project identification and file metadata
111+
* - Creation and modification timestamps
112+
* - Description, purpose, and copyright information
113+
* - Telegraph protocol markers for structured communication
114+
* - Closing decoration and formatting
115+
*
116+
* Performance Considerations:
117+
* - Language configurations cached after first load
118+
* - Header parsing optimized for large files
119+
* - Minimal VS Code API calls to reduce overhead
120+
* - Efficient string manipulation and template processing
121+
*
122+
* @example Advanced usage with configuration:
123+
* ```typescript
124+
* const generator = new CommentGenerator(configLoader);
125+
* generator.updateLogoInstanceRandomiser(logoProvider);
126+
*
127+
* // Configure behavior
128+
* await generator.refreshHeader(document, {
129+
* forceUpdate: true,
130+
* preserveDescription: false
131+
* });
132+
* ```
52133
*/
53134
export class CommentGenerator {
54135
/** @brief Configuration object containing all extension settings */
@@ -200,8 +281,8 @@ export class CommentGenerator {
200281
const extensionsForLang = nodeFileExtensions[langName] ?? [];
201282
for (let extIndex = 0; extIndex < extensionsForLang.length; extIndex++) {
202283
let dot: string = "";
203-
if (extensionsForLang[extIndex].length >0 && extensionsForLang[extIndex][0] === ".") {
204-
dot=".";
284+
if (extensionsForLang[extIndex].length > 0 && extensionsForLang[extIndex][0] === ".") {
285+
dot = ".";
205286
}
206287
if (extensionsForLang[extIndex] === `${dot}${this.fileExtension}`) {
207288
nodeFound = true;
@@ -215,6 +296,7 @@ export class CommentGenerator {
215296
}
216297
}
217298

299+
logger.debug(getMessage("arrayNodeContent", `Json[${primaryKey}]`, index, node));
218300
if (nodeFound) {
219301
logger.Gui.info(getMessage("identifiedLanguage", locatedName));
220302
logger.info(getMessage("arrayNodeContent", `Json[${primaryKey}]`, index, node));
@@ -223,7 +305,6 @@ export class CommentGenerator {
223305
commentStructure.prompt_comment_opening_type = node.prompt_comment_opening_type ?? false;
224306
return commentStructure;
225307
}
226-
logger.debug(getMessage("arrayNodeContent", `Json[${primaryKey}]`, index, node));
227308
}
228309
logger.error(getMessage("languageNotFound", String(this.languageId), this.fileExtension));
229310
return commentStructure;

0 commit comments

Comments
 (0)