Sourcetrail / Coati

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Sourcetrail / Coati

Post by saso »

Image

https://github.com/CoatiSoftware/Sourcetrail
Sourcetrail is an interactive source explorer that simplifies navigation in existing source code. Sourcetrail's aim is to give answers to all your questions about your source code. Sourcetrail first indexes your code and gathers data about its structure and then provides you a simple interface consisting of three interactive views, each playing a key role in getting information:

- Search: Use the search field to quickly find and select indexed symbols in your source code. The autocompletion box will instantly provide an overview of all matching results throughout your codebase.

- Graph: The graph displays the structure of your source code. It focuses on the currently selected symbol and directly shows all incoming and outgoing dependencies to other symbols.

- Code: The Code view displays all source locations of the currently selected symbol in a list of code snippets. Clicking on a different source location allows you to change the selection and dig deeper.

Sourcetrail - Introduction
https://www.youtube.com/watch?v=Cfu6f0uyzc8
https://www.youtube.com/channel/UCuKthd ... VpQ/videos

The Untapped Potential of Software Visualization
https://www.youtube.com/watch?v=fnIFVYFspfc
Last edited by saso on Sat Jun 10, 2023 8:50 am, edited 11 times in total.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

I was trying for the full past week building the index for the FreeCAD python code but still was not able to get it done more then about 25% (true, I was also running it on an old and slow machine)... Today I changed to a bit faster machine and took a bit closer look at the indexed py files and excluded the five large files * from ...\src\Mod\Import\App and the indexing finished in 2h 23min... Much better :)

* ifc4.py, automotive_design.py, ap203_configuration_controlled_3d_design_of_mechanical_parts_and_assemblies_mim_lf.py, ifc2x3.py, config_control_design.py

Python support was added to Sourcetrail quite recently, so there is also hope for further improvements...

Update: So using the "Compilation Database" method (since we are using cmake) the initial indexing of the C++ code was also easy :)
https://www.youtube.com/watch?v=7fguPwKR_7Y
Last edited by saso on Fri Jun 09, 2023 8:26 pm, edited 3 times in total.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

"The Sourcetrail 2019.3 release introduces the new Custom Trail dialog to query and display custom graphs that show connections between any two symbols. Additionally, the new release brings Precompiled Header (PCH) Support for C and C++ projects to speed up the indexing step..."
Last edited by saso on Fri Jun 09, 2023 8:26 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Sourcetrail / Coati

Post by Kunda1 »

saso wrote: Tue Aug 27, 2019 4:54 pm
Installed. I'm creating a new "Source Group" now.
Which should I choose? Can I choose 1 for cpp and another for python?
Image
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

Kunda1 wrote: Mon Sep 16, 2019 12:35 pm Installed. I'm creating a new "Source Group" now.
Which should I choose? Can I choose 1 for cpp and another for python?
Yes, this is how I did it, one for C++ and one for Python, I am not sure if it is possible to do them together... Check my comments and links above how to make the builds (I used the "Compilation Database" method for C++ build and excluded some files from the python build). Also check the tutorial and demo projects that come with the program to understand how to navigate and use it. Note that this is a tool quite specific for developers to navigate and read the source code. I think it should be however possible to pre-build and share the database, might be easier for some users.
Last edited by saso on Mon Sep 16, 2019 1:51 pm, edited 1 time in total.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

saso wrote: Mon Sep 16, 2019 12:56 pm I think it should be however possible to pre-build and share the database, might be easier for some users.
Here are my two older builds (I think from commit 17300, jul 2019)... For someone that is just interested to have a quick view at this they can be fine, since one should be able to just open them in Sourcetrail and start playing with it. For developers it is better if they make their own builds, from more recent commits and there are also quite a few indexing errors reported in this builds, resolving them would be good :roll:

removed since the old builds don't work anymore in newer versions
Last edited by saso on Sun Feb 23, 2020 2:55 pm, edited 1 time in total.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

Last edited by saso on Fri Jun 09, 2023 8:27 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Sourcetrail / Coati

Post by Kunda1 »

Thanks for the heads-up ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sourcetrail / Coati

Post by saso »

Development of the Sourcetrail was unfortunately stopped at the end of 2021, but I was thinking to check if it can still be somehow useful...

Linked below is an pre-indexed database of the recent FreeCAD master (commit 33383, hash 14dd2c60ec630e7a590b39c3dcee28111284717d) for all the python code in /src created with the last version of Sourcetrail_2021_4_19 https://github.com/CoatiSoftware/Source ... /2021.4.19

This version is meant just to quickly test and play a bit with it, I am guessing this can be shared and used like this, so users don't have to spend the time setting it up and running it by themselves, since indexing can take quite some time... This way it should be as simple as opening the project file (.srctrlprj from the archive) in the latest version of Sourcetrail. Would be good to know if it is working for others also on different systems etc. but of course those who prefer to set it up by themselves can also do that.

For the general functionality of Sourcetrail, check some of the YouTube videos and the demo projects and tutorial that comes with the program (the old homepage is unfortunately gone).

So some questions would be... Is it working? Is it useful? How can it be improved, what else should be excluded to make it more clean and what else to include, and how, to fix all the reported errors...? This was indexed from the source, would it maybe be better to index it from the build/installed version? Would it make more sense to have it done for individual workbenches instead of the complete master? If a useful version of it can be made, would it make sense to have it available and updated more regularly?

https://mega.nz/file/nVR0CBKS#f2uPUKkKQ ... nheV-xbhfs

Hopefully I will find the time in the next days to also make it for the c++ code...
Post Reply