Skip to content

Tree Core Architecure

Ralph Maamari edited this page Jun 10, 2020 · 31 revisions

This page is meant for anyone who wants to learn more about the internal Data Structures this repository uses to generate the markdown accessible & hyperlink enabled project structure's for README's to help beginner developers understand how to approach a codebase.

Tree Core

Tree Core is an array of Core's which is the internal data structure used the represent a file. Tree Core is an array of Core's which essentially is the repository file structure. Note that file's could be folders and thus contain their own "Tree" of files inside it. Note that during a deletion, nothing is ever deleted from the tree just marked as if it was deleted.

Configuration

Core: {
  path: string,   // Store's Original File Path provided by Github API
  comment: string, // Store's the Comment generated by the folder / Store's Edits
  deletedOrder: number // -1 means not deleted. 0 means first deleted. In a batch deletion, everything gets the same incremented number.
  treeCore: ...TreeCore,  // Store's all the files underneath this folder
};

Deletion

Global Instance Client-Side Variables (Can be accessed by any function without passing it)
lastDeletedOrder: number (The Last Deletion Number that occurred)

Recursion

// The Index of the Array outlines the Display Positioning on the Web App
// The TreeCore recursive structure will allow us to pull depth level out through recursion
// This is done because Folders can contain Folders which can contain Folders...You get the idea.
TreeCore: Core[];

Methods

Tree Core comes with Assistive Functions to help extract data from Tree Core using inferences to keep Tree Core as light as possible.

Markdown Generation

Generate the MarkDown Accessible Tree

const generateMarkDownTree = (treeCore: TreeCore): string => {}

const getCopyToClipboardContents = (treeCore: TreeCore): string => {
  // Will be the MarkDownTree without the deletedCore's (Any core with deletedOrder > -1)
}

Comments

const getCommentForPath = (path: string): string => {
  // Retrieves the auto generated comments for common folders
}
const setCommentForPath = (path: string, comment: string): void => {
  // Sets comment for a path (Editing)
}

Hyperlinks

Generate the hyperLink of a specific file

const getHyperLinkFromPath = (path: string): string => {}

Filetypes

Retrieve the fileType of a specific file.

const getFileTypeFromPath = (path: string): FileType => {}

FileIcons

Retrieve the FileIcons of a specific FilType.

const getFileIconFromFileType = (fileType: FileType): Icon => {
  // References the IconToFile Mapping Object to return the correct Icon
}

Retrieve the longest path length in a level for comment alignment

const getLargestPathLengthInLevel = (treeCore: TreeCore, depthLevel: number): number => {
  // If depthLevel is outOfBounds this will return -1
}

Deletion

Delete a specific File

const deleteFileFromPath = (treeCore: TreeCore, path: string): void => {
  // lastDeletedOrder is used by this function (Global Variable)
  // Must keep a constant eye on depthLevel's Largest Path String (For Comment Spacing) as traversal
  // If deleted element exceeds or matches largest path string then conduct a TreeGeneration otherwise, just delete
  // IF the file is a FOLDER, then everything inside the folder (Recursively is set to lastDeletedOrder)
  // lastDeletedOrder is increased by 1 (ONLY ONE AT ANY TIME THIS FUNCTION IS CALLED)
}

Undo Deletions

Undo the Last X Deletions (Ctrl+Z)

const undoDeletions = (treeCore: TreeCore, undoNumber: number = 1): void => {
  // lastDeletedOrder is used by this function (Global Variable)
  // Everything in the TreeCore that has a deletedOrder with the range of (lastDeletedOrder - undoNumber)
  // Ex: LDO = 5, UN = 3, means anything with numbers 5,4,3 will has their deletedOrder set to -1 (No Longer Deleted).
  // Save the new deletedOrder number EX: LDO = 2.
}