Skip to content

Commit

Permalink
CT 1.62 - aot removed short project-name-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
some-avail committed Jun 28, 2024
1 parent 9153169 commit 3c20b39
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
[Go to the user-manual](mostfiles/manual_codetwig.txt)


#### Forthcoming version: 1.61
#### Forthcoming version: 1.62

### Description CodeTwig

CodeTwig (CT) is terminal-program to view the outline of the source-code and to show procedures as usage-trees or used-by-trees. Some features are still to be added. See future-plans below. Currently only meant for Nim.

#### Features
- CT scans the source-code-files on basis of the project you have defined.
- It creates a declaration-list in which all declarations like procs and templates are listed.
- CT scans the source-code-files on basis of the project you have defined and adds the files from all underlying directories (after which you can prune the list).
- It creates a declaration-list in which all declarations like procs and templates are listed
- The declaration-list is used to generate 4 text-files that give specific views of the project.
- CT can also show (for a certain declaration / proc) the usage-trees and used-by trees on basis of the dec-list, and gives with it the arguments and the comment-section.
- a source-code-view option (-c:s); search and show the full source-code of the proc /declaration.
- flexible semicolumn-separated search: declaration;module;project
- CT can combine dec-list of multiple projects and thus show trees for multiple projects (multiproject-feature).
- multiproject-feature; CT can combine dec-list of multiple projects and thus show trees for multiple projects (multiproject-feature).
- all functions are called by entering terminal-commands, allthough the generated view-files can be watched by themselves of course.


Expand Down Expand Up @@ -49,19 +50,17 @@ Or look at the commits.


#### Completed from future plans
- ct 1.61
- add a source-code-view option (c:s); after searching show the full source-code of the proc /declaration.
- ct 1.56
- recursively scan multiple dir-levels for source-files.
- added a project-field so that multiple projects can be added to one declaration-list to enable multi-project search.
- added flexible semicolumn-separated search: declaration;module;project
- 1.62
- removed bug caused by short project-names
- added declaration-types method, iterator and converter


### Remaining future plans:

### Remaining future plans:
- add an options-file (for example for customizing the number of comment-lines)
- multiproject-level regeneration of individual project-files.
- within search do enable line-start-appending to be able to uniquify overloaded names
- limit decs in the usage-tree to the imported modules (optionize).
- multiproject-level regeneration of individual project-files.


### Maybe ever?
Expand Down
49 changes: 31 additions & 18 deletions mostfiles/ctwig.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import std/[os, strutils, paths, tables, parseopt]


var
versionfl: float = 1.61
versionfl: float = 1.62
codetwigst: string = "CodeTwig"
ct_projectsdirst: string = "projects"
dec_list_suffikst: string = "dec_list.dat"
Expand Down Expand Up @@ -429,7 +429,7 @@ proc createDeclarationList(proj_def_pathst: string) =
fileob, phase1fileob, phase2fileob, phase2file2ob, phase3fileob: File
source_filesq: seq[string]
# declaration-types
nim_dec_typesq: seq[string] = @["proc", "template", "macro", "func"]
nim_dec_typesq: seq[string] = @["proc", "template", "macro", "func", "iterator", "method", "converter"]
langekst: string = "nim"
filepathst: string
sourceprojectpathst, reltargetprojectpathst: string
Expand Down Expand Up @@ -460,6 +460,7 @@ proc createDeclarationList(proj_def_pathst: string) =
dec_plus_modulest, previous_modulest: string

projectnamest, fullmodpathst, modfilest, submodulest: string
projectprefikst: string

try:

Expand All @@ -478,10 +479,10 @@ proc createDeclarationList(proj_def_pathst: string) =
else:
echo "Using target-directory for your " & codetwigst & "-project: " & reltargetprojectpathst


phase1_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase1_" & dec_list_suffikst))
phase2_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase2_" & dec_list_suffikst))
phase3_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))
projectprefikst = clipString(string(pd_filebasepa), 7)
phase1_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase1_" & dec_list_suffikst))
phase2_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase2_" & dec_list_suffikst))
phase3_dec_list_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))


# first phase; create first intermediate product phase1_dec_list_filepathst
Expand Down Expand Up @@ -827,6 +828,8 @@ proc createCodeViewFile(proj_def_pathst: string, viewtypeeu: ViewType) =
linestartit, lineendit: int
commentlinesq, doublehashsq, singlehashsq: seq[string]
choppedmodulest, projectnamest, toptitlest: string
projectprefikst: string


try:
# retrieve project-data from project-def-file
Expand All @@ -841,11 +844,14 @@ proc createCodeViewFile(proj_def_pathst: string, viewtypeeu: ViewType) =
echo "--------------------------------------------------------"
echo "Using target-directory for your " & codetwigst & "-project: " & reltargetprojectpathst

decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))
boview_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_basic_one-level_view.txt"))
btview_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_basic_two-level_view.txt"))
eoview_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_extended_one-level_view.txt"))
etview_filepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_extended_two-level_view.txt"))

projectprefikst = clipString(string(pd_filebasepa), 7)

decfilepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))
boview_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_basic_one-level_view.txt"))
btview_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_basic_two-level_view.txt"))
eoview_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_extended_one-level_view.txt"))
etview_filepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_extended_two-level_view.txt"))


decfilob = open(decfilepathst, fmRead)
Expand Down Expand Up @@ -1276,6 +1282,7 @@ proc writeFamily(proj_def_pathst, declarationst, modulest, directionst: string,
inputst, outputst: string
onelinest, declarest, usedatalinest, indentationst, decdatalinest: string
choppedmodulest, decfilecontentst: string
projectprefikst: string


try:
Expand All @@ -1284,7 +1291,8 @@ proc writeFamily(proj_def_pathst, declarationst, modulest, directionst: string,
var (pd_dirpa, pd_filebasepa, pd_extst) = splitFile(Path(proj_def_pathst))
reltargetprojectpathst = string(Path(ct_projectsdirst) / pd_filebasepa)

decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))
projectprefikst = clipString(string(pd_filebasepa), 7)
decfilepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))
decfileob = open(decfilepathst, fmRead)
decfilecontentst = readAll(decfileob)

Expand Down Expand Up @@ -1371,7 +1379,7 @@ proc echoDeclarationData(proj_def_pathst, declarationst, modulest: string, proje
linestartit, lineendit: int
commentlinesq, singlehashsq, doublehashsq: seq[string]
reconstructed_project_def_pathst, decfilecontentst: string

projectprefikst: string

try:
wispbo = false
Expand All @@ -1392,7 +1400,8 @@ proc echoDeclarationData(proj_def_pathst, declarationst, modulest: string, proje
var (pd_dirpa, pd_filebasepa, pd_extst) = splitFile(Path(proj_def_pathst))
reltargetprojectpathst = string(Path(ct_projectsdirst) / pd_filebasepa)

decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))
projectprefikst = clipString(string(pd_filebasepa), 7)
decfilepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))
decfileob = open(decfilepathst, fmRead)
decfilecontentst = readAll(decfileob)

Expand Down Expand Up @@ -1495,7 +1504,7 @@ proc showDeclarationBranch(proj_def_pathst, directionst: string, maxdepthit: int
inputst, outputst: string
onelinest, declarest, modulest, dectypest, linestartst, projecst: string
projecttypest, projectst, decfilecontentst: string

projectprefikst: string


try:
Expand All @@ -1516,7 +1525,9 @@ proc showDeclarationBranch(proj_def_pathst, directionst: string, maxdepthit: int
echo "--------------------------------------------------------"
echo "Direction (tree-type) = ", directionst, ", Maxdepth = ", maxdepthit
echo "Enter: declaration;module;project to view specific items, emtpy for all items, or exit to exit: "
decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))

projectprefikst = clipString(string(pd_filebasepa), 7)
decfilepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))

decfilob = open(decfilepathst, fmRead)
decfilecontentst = decfilob.readAll()
Expand Down Expand Up @@ -1698,7 +1709,7 @@ proc showSourceCode(proj_def_pathst: string) =
inputst, outputst: string
onelinest, declarest, modulest, dectypest, linestartst, lineendst, projecst: string
projecttypest, projectst, decfilecontentst: string

projectprefikst: string


try:
Expand All @@ -1719,7 +1730,9 @@ proc showSourceCode(proj_def_pathst: string) =
echo "--------------------------------------------------------"
echo "To show the source-code of the declaration:"
echo "Enter: declaration;module;project to view specific items, emtpy for all items, or exit to exit: "
decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))

projectprefikst = clipString(string(pd_filebasepa), 7)
decfilepathst = string(Path(reltargetprojectpathst) / Path(projectprefikst & "_phase3_" & dec_list_suffikst))

decfilob = open(decfilepathst, fmRead)
decfilecontentst = decfilob.readAll()
Expand Down
7 changes: 5 additions & 2 deletions mostfiles/whatsnew_codetwig.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
What's new in CodeTwig?

1.6x
1.62
- removed bug caused by short project-names
- added declaration-types method, iterator and converter

1.61
- enable the showing of full declarational source-code with a new command -s
- improved comment-rendering


1.56
- recursive scanning of subdirs for source-files.
- multiproject enables creation of a multi-project declaration-list and thus treeviews
Expand Down

0 comments on commit 3c20b39

Please sign in to comment.