Enhances code documentation and structure for plugin #3

Merged
AlexKucera merged 20 commits from docstrings into master 2025-10-25 10:50:22 +02:00
Showing only changes of commit bd5321b69e - Show all commits
+9 -3
View File
@@ -65,13 +65,18 @@ export default class FreewritingCleanupPlugin extends Plugin {
* Loads plugin settings from Obsidian storage
*
* Merges stored settings with defaults to ensure all required fields exist.
* Excludes modelCache from settings object to keep types clean.
* Returns the raw data for reuse in cache loading.
*
* @returns Raw plugin data including settings and optional cache, or null if no data exists
*/
async loadSettings(): Promise<FreewritingCleanupData | null> {
const data = await this.loadData() as FreewritingCleanupData | null;
this.settings = Object.assign({}, DEFAULT_SETTINGS, data);
const { modelCache, ...persisted } = data ?? {};
this.settings = {
...DEFAULT_SETTINGS,
...(persisted as Partial<FreewritingCleanupSettings>)
};
return data;
}
@@ -101,11 +106,12 @@ export default class FreewritingCleanupPlugin extends Plugin {
* Registers the cleanup command with Obsidian
*
* Creates the "Clean up text" command with editor callback that executes
* the cleanup operation on selected text.
* the cleanup operation on selected text. Command ID is prefixed with plugin
* ID to avoid future collisions and maintain stability post-release.
*/
private registerCommand() {
this.addCommand({
id: 'cleanup-text',
id: 'freewriting-cleanup-cleanup-text',
name: 'Clean up text',
editorCallback: async (editor: Editor, view: MarkdownView) => {
await this.executeCleanupCommand(editor, view);