Language-Agnostic Generation of Header Comments using Large Language Models
Nathanael Yao, Juergen Dingel, Ali Tizghadam, Ibrahim M. Amer · 2025
Documentation comments are essential for maintainability, yet they are often missing or outdated. This is true not only for programs in general-purpose languages, but also for artifacts in other languages often found in software projects such as scripts or configuration files. To address this problem, we present an approach that uses Large Language Models (LLMs) to generate header comments (aka, ‘block comments’ or ‘doc-strings’) for elements of different languages in different documentation formats. Given a file in some language and a description of elements in the file to be documented and the documentation format to be used, the approach generates header comments for all undocumented elements in the file that is guaranteed to conform to the documentation format. We describe a prototype implementation and its integration into an industrial development pipeline. Feedback from our industrial partner, an LLM-as-judge evaluation, and the participants of a user study involving a broad range of languages indicates that the approach is viable, able to produce sufficiently high-quality documentation in general, and holds potential for improving industrial documentation practices across different programming languages and teams.