Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:17:32+00:00 2026-06-14T06:17:32+00:00

I want to do some refactoring of code, especially the include-like relationships between files.

  • 0

I want to do some refactoring of code, especially the “include”-like relationships between files. There are quite a few of them, and to get started, it would be helpful to have a list, diagram, or even a columnar graph, so that I can see at a glance what is included from where.

(In many cases, a given file is included by multiple other files, so the graph would be a DAG, not a tree. There are no cycles.)

I’m working with TeX (actually ConTeXt), but the question would seem to apply to any programming languages that has a facility like that of #include in C.

The obvious, easy answer is to do a grep or “Find in Files” on all the .tex files for the relevant keywords (\usemodule, \input, and a couple of other macros we’ve defined). This is better than nothing, but the output is long, and it’s still difficult to see patterns in what includes what. For example, is file A usually included before file B? Is file C ever included multiple times by the same file?

I guess that brings out an additional, but optional feature: that such a tool would be able to show the sequence of includes from a particular file. So in that case the DAG could be a multigraph, i.e. there could be multiple arcs from one file to another.

Ideally, it would be nice to be able to annotate each file, giving a very brief summary of what’s in it. This would form part of the text on the graph node for that file.

Probably this sort of thing could be done with a script that generates graphviz dot language. But I wanted to know if it has already been done, rather than reinvent the wheel.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:17:34+00:00Added an answer on June 14, 2026 at 6:17 am

    As it is friday in my country right now, and I’m waiting for my colleagues to go to have a beer, I thought I’d do a little programming.

    Here http://www.luki.webzdarma.cz/up/IncludeGraph.zip you can download source of a really simple utility that looks for all files in one folder, parses #includes and generates a .dot file for that.

    It supports and correctly handles relative paths, and works on windows and should work on linux as well. It is written in very spartan way. My version of dot is not parsing the generated files, there is some bug, but I really need to go drinking now, see if you can fix it. I’m not a regular dot user and I dont see it, though I’m sure it is pretty obvious.

    Enjoy …

    PS – If you run into trouble compiling and/or running, please let me know. Thanks.

    EDIT

    Ok, my bad, there was a few glitches on linux. The dot problem was it was using "graph" instead of "digraph". But it is working like charm now. Here is the link. Just type make, and if that goes, make test should generate the following diagram of the program itself:

    An inclusion graph

    It ignores preprocessor directives in the C++ files so it is not very useful for that directly (could be fixed by simply calling g++ with preprocessor output flag and processing that instead of the actual files). I didn’t get to regexp today, but if you have any programming experience, you will find that modifying DotGraph.cpp shouldn’t be very hard to hard-code your inclusion token, and to change list of file extensions. Might get to regexp tomorrow or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm refactoring some code in C++, and I want to deprecate some old methods.
I'm refactoring some code that currently looks like this: $$('#wrapper > div').each(function(e){ if((e.id!='header') &&
I'm refactoring some code and want to classes a bit higher in the inheritance
I'm refactoring some older code and want to make sure I understand the previous
I want some code to be triggered every second. Usually, I'd create a Timer
I want some of the goodies in a ListView, like being able to use
I want some like this: How make it ideologically correct?
So here is the scenario, I am refactoring some spaghetti code. My first problem
I unfortunately was doing a little code archeology today (while refactoring out some old
I'm refactoring some code I didn't write, that contains business logic and proprietary algorithms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.