Skip to content

Commit 4ddd5bc

Browse files
Thomas CRATERThomas CRATER
authored andcommitted
Creation of helper popup and modification of fileP
1 parent f273492 commit 4ddd5bc

16 files changed

+205
-67
lines changed

package-lock.json

Lines changed: 53 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@emotion/react": "^11.14.0",
1414
"@emotion/styled": "^11.14.0",
15+
"@mui/icons-material": "^6.4.2",
1516
"@mui/material": "^6.3.1",
1617
"file-saver": "^2.0.5",
1718
"jspdf": "^2.5.2",

src/functions/FileParsing.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ const FileParsing = async (formData, rows) => {
77
const filesParsed = [];
88

99
for (const fileEntry of files) {
10-
const [fileName] = fileEntry.name.split(".");
10+
const [fileName, ...extParts] = fileEntry.name.split(".");
11+
const extension = extParts.length ? extParts.join(".") : "";
1112

1213
for (const row of rows) {
1314
if (fileName === row.file) {
1415
const file = await fileEntry.getFile();
1516
const content = await file.text();
1617
const functions = [];
17-
18-
const lines = content.split("\n");
1918
let pendingComments = [];
2019
let insideBlockComment = false;
2120
let blockCommentBuffer = "";
2221

22+
const lines = content.split("\n");
23+
2324
for (let i = 0; i < lines.length; i++) {
2425
let line = lines[i].trim();
2526

@@ -41,22 +42,49 @@ const FileParsing = async (formData, rows) => {
4142
}
4243
}
4344

44-
if (i + 1 < lines.length) {
45-
let nextLine = lines[i + 1].trim();
45+
let nextIndex = i + 1;
46+
while (nextIndex < lines.length && lines[nextIndex].trim() === "") {
47+
nextIndex++;
48+
}
49+
50+
let nextLine = nextIndex < lines.length ? lines[nextIndex].trim() : "";
51+
52+
let isFunctionDeclaration =
53+
nextLine.startsWith("const ") || nextLine.indexOf("function") !== -1;
54+
55+
if (isFunctionDeclaration) {
56+
let functionName = "";
57+
4658
if (nextLine.startsWith("const ")) {
4759
let functionStart = nextLine.indexOf("const") + 6;
4860
let functionEnd = nextLine.indexOf(" ", functionStart);
61+
if (functionEnd !== -1) {
62+
functionName = nextLine.substring(functionStart, functionEnd).trim();
63+
}
64+
} else if (nextLine.indexOf("function") !== -1) {
65+
let functionStart = nextLine.indexOf("function") + 9;
66+
let functionEnd = nextLine.indexOf(" ", functionStart);
67+
if (functionEnd !== -1) {
68+
functionName = nextLine.substring(functionStart, functionEnd).trim();
69+
}
70+
}
4971

50-
if (functionEnd !== -1 && pendingComments.length > 0) {
51-
let functionName = nextLine.substring(functionStart, functionEnd).trim();
72+
if (functionName && pendingComments.length > 0) {
73+
functions.push({
74+
functionName: functionName,
75+
comments: [...pendingComments],
76+
});
5277

53-
functions.push({
54-
functionName: functionName || "",
55-
comments: [...pendingComments],
56-
});
78+
pendingComments = [];
79+
}
80+
} else {
81+
if (pendingComments.length > 0) {
82+
functions.push({
83+
functionName: "",
84+
comments: [...pendingComments],
85+
});
5786

58-
pendingComments = [];
59-
}
87+
pendingComments = [];
6088
}
6189
}
6290
}
@@ -72,4 +100,4 @@ const FileParsing = async (formData, rows) => {
72100
return filesParsed;
73101
};
74102

75-
module.exports = FileParsing;
103+
module.exports = FileParsing;

src/functions/FilesArray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const ToArrayExtensions = require("./ToArrayExtensions");
22
const FilterFiles = require("./FilterFiles");
33

4-
// Doc: documentation d'explication de l'affichage des fichiers pris en charge par la generation de la documentation
5-
const FilesArray = async (files, extensionsName) => {
4+
// Doc: fonction permettant l'affichage des fichiers pris en charge par la generation de la documentation
5+
async function FilesArray (files, extensionsName) {
66
if (!extensionsName || typeof extensionsName !== "string" || extensionsName.trim().length === 0) {
77
return [];
88
}

src/functions/FilesSelector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Doc: fonction permettant de sélectionner les différents fichiers
2+
13
const FilesSelector = async () => {
24

35
const pickerOptions = {

src/functions/FilterFiles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// doc: Cette fonction filre les fichiers selon les extensions choisis et renvoie le tableau des fichiers filtres
2+
13
const FilterFiles = async (files, extensions) => {
24
let filesArray = [];
35
let filesArrayResult = [];

src/functions/FolderSelector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const GetAllFiles = require("./GetAllFiles");
22

3+
// doc: Fonction pour sélectionner un dossier
34
const FolderSelector = async () => {
45
try {
56
const directoryHandle = await window.showDirectoryPicker();

src/functions/GetAllFiles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
async function GetAllFiles(directoryHandle, files) {
1+
// Doc: Permet d'attraper récursivement les fichiers dans les différents dossiers et sous-dossier
2+
3+
const GetAllFiles = async (directoryHandle, files) => {
24
for await (const entry of directoryHandle.values()) {
35
if (entry.kind === "file") {
46

src/functions/OutputNameFileMarkdown.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// doc: ajoute le .md a la fin du project Name
2+
13
const OutputNameFileMarkdown = (projectName) => {
24
const extension = ".md";
35
const outputNameFileMarkdown = projectName.concat(extension);

src/functions/OutputNameFilePDF.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// doc: ajoute le .pdf a la fin du project Name
2+
13
const OutputNameFilePDF = (projectName) => {
24
const extension = ".pdf";
35
const outputNameFilePDF = projectName.concat(extension);

0 commit comments

Comments
 (0)