Skip to content

feat: json export support#186

Closed
renesat wants to merge 1 commit intoiwe-org:masterfrom
renesat:json-export
Closed

feat: json export support#186
renesat wants to merge 1 commit intoiwe-org:masterfrom
renesat:json-export

Conversation

@renesat
Copy link
Contributor

@renesat renesat commented Nov 14, 2025

Added export to JSON. It is very useful if used for external tools. I just used the internal graph format. I can do something else, but I think it's a good option and there was almost nothing to refine.

@gimalay
Copy link
Contributor

gimalay commented Nov 16, 2025

@renesat thanks for the PR! Could you please describe your use-case so I understand the context better? How exactly you plan to use the exported json?

I would like to make sure that the export format makes sense, cause it a contract I will need to maintain over long period of time to make sure that we are not breaking integrations for the people who are using it.

Also, since this is a new feature, it will require a test and docs update.

@renesat
Copy link
Contributor Author

renesat commented Nov 17, 2025

Okay, I'll write the tests and fix the documentation.

But I think I found a bug here. The test_export_dot_basic test creates two files: test.md and related.md. But only one is exported (I checked this on master, without my changes):

digraph G {
  rankdir=LR
  fontname=Verdana
  fontsize=13
  nodesep=0.7
  splines=polyline
  pad="0.5,0.2"
  ranksep=1.2
  overlap=false
  6[label="Test Document",fillcolor="#ffeee0",fontsize=16,fontname=Verdana,color="#b3b3b3",penwidth=1.5,shape=note,s
tyle=filled]
}

There may be a mistake in creating GraphData or I'm missing something. I didn't dig deep, but it's strange that this is on master, where I just added the output of the resulting graph on the test data.

@renesat
Copy link
Contributor Author

renesat commented Nov 17, 2025

I'm not sure, but the error is most likely somewhere in Graph::paths. For some reason, the path with a length of 1 is only 1 in this case, and when filtering, we only get test.md.

@gimalay
Copy link
Contributor

gimalay commented Nov 18, 2025

@renesat could you please explain what problem you are trying to solve? How you want to use json export, what is the use case?

@renesat
Copy link
Contributor Author

renesat commented Nov 18, 2025

could you please explain what problem you are trying to solve? How you want to use json export, what is the use case?

Well, I was thinking of using it for external visualization and statistical analysis. In general, JSON is the de facto standard for data transfer. You can transfer it to jq or practically any tool for further processing.

But here I found a problem that wasn't even in my PR. When I was writing the test, I noticed that the graph and dot_export weren't working correctly on the test example. Or should it only output test.md at a depth of 0?

It just seems more logical to me to export all data by default. And if you don't need everything, then use parameters.

@gimalay
Copy link
Contributor

gimalay commented Nov 22, 2025

IWE build around the idea of MoC based documents hierarchy. The documents which are not part of any other documents considered roots. For example you can have Projects.md with all your projects referenced in it will make Projects.md a root and actual project leafs in the graph. The default export mode is - finding all the root documents and traversing the graph starting from them.

You can read more here https://github.com/iwe-org/iwe/blob/master/docs/maps-of-content.md

Could you please explain what type of processing you want to do with the JSON data and what structure of the JSON you would need? I can help you more with understanding of your intent.

@renesat
Copy link
Contributor Author

renesat commented Dec 1, 2025

I would like to highlight as much information as possible, but as an example, I had the idea for myself to make a visualizer like org-roam-ui and export the information to my personal db. But how could anyone use this if they want to do something like plugins, additional analysis systems, and so on.

Well, the main thing I need is nodes and metadata about them: file, id, title, etc.

@gimalay
Copy link
Contributor

gimalay commented Dec 2, 2025

It would be awesome to have a visualizer for IWE. We can collaborate on this if you are interested. Are you thinking about using web stack?

@gimalay gimalay closed this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants