About adding extra source code snippets of others crates in generated markdown files from rustdoc JSON

I was working on a cli tool that I can use to generate structured markdown docs (for my own project + the docs of its dependencies) with extensive reference links for various types (like html docs) that I can use to jump directly to where that type is documented in. For example, I already have added the "Defined in ..." part using the source span provided in rustdoc JSON, this is not provided in docs (as far as I know). The tool automatically copies the source code of my projects dependencies, to my project root and renames all of their Cargo.toml to Crate.toml so that rust-analyzer doesn't pick them up. This allows me to have local docs + source code of the dependencies I can look through in various ways. The link in image takes you directly to the exact location that function is defined in the source code of that crate (in this case syn). You can check this in the repo if you want to.

Would it be okay if I added the source code snippet directly into the markdown files, that are basically from someone else's project and they are probably not expecting their code to be used in such a way? I am thinking about providing the full docs in the repo of my projects, so I guess I should clear up whether I can keep this project public, or should I make it private and keep it only for my personal use?

Anyone knowledgeable about these things (licenses etc), please leave a comment if you know something about this. I have already spent a lot of time working this project :'D

This is fundamentally a question about copyright law, and whether your snippets are (in US terms) “fair use” or not. Definitive answers don’t exist and the closest approximation can only be obtained by talking to an intellectual property lawyer.

It is very likely that publishing such documentation would be just fine in practice, by the criteria of “will you get sued about it” (assuming you apply it only to open-source and not proprietary code, of course). But that’s just my guess about what people will care about. I am not a lawyer, and especially not your lawyer.

2 Likes

It's only going to get used in docs, so they won't really be used in any 'code'... I guess I will just feature gate that and continue working it for now and keep this post open. If someone objects with a valid reason I will just remove the feature gated parts.

If all you’re talking about is publishing a tool that creates such documents, not publishing the documents, then that’s no different than, say, rustdoc itself.

1 Like

Thanks for your input. I am marking this thread as solved. Because that's exactly what I am doing, the tool can be used to provide the docs of both your project and all of its dependencies directly in your repo as crate/module level structured markdown files. It still does not diverge that much from rustdoc itself (maybe just SOME extra source code where relevant, but that is not default behavior), apart from the html format.