Documentation generation

Summary

Documentation generation can be used to automatically generate of documentation for the entire input file.

Example

To use the documentation generation feature create a new file. As an example of documentation generation for Java programming language, we will use a class name PaymentDao.

public class PaymentDao {

    private static final Logger logger = LoggerFactory.getLogger(PaymentDao.class);
    
    private final Session session;
    
    public PaymentDao(Session session) {
        this.session = session;
    }
    
    public void save(Payment payment) {
        if (payment == null) {
            throw new IllegalArgumentException("Payment cannot be null");
        }
        try {
            session.beginTransaction();
            session.save(payment);
            session.getTransaction().commit();
        } catch (Exception e) {
            logger.error("Error while persisting payment", e);
            session.getTransaction().rollback();
        }
    }
    
    public void update(Payment payment) {
        try {
            session.beginTransaction();
            session.update(payment);
            session.getTransaction().commit();
        } catch (Exception e) {
            logger.error("Error while updating payment", e);
            session.getTransaction().rollback();
        }
    }
    
    public Payment get(String id) {
        return (Payment) session.get(Payment.class, id);
    }
    
    public void delete(Payment payment) {
        try {
            session.beginTransaction();
            session.delete(payment);
            session.getTransaction().commit();
        } catch (Exception e) {
            logger.error("Error while deleting payment", e);
            session.getTransaction().rollback();
        }
    }
}

Generating documentation

In the provided example the source file defines a set of methods. CodeMaker AI can process the entire file and generate the documentation for the file, in this case any existing documentation will remain intact.

Generating documentation using Visual Studio Code

Generating documentation using JetBrains IDE

Generating documentation using CodeMaker CLI

  1. Executed command in the terminal: codemaker generate docs **/PaymentDao.java

Replacing documentation

Similarly to generating documentation for an existing code it is possible to replace the documentation across the entire file.

Replacing documentation using Visual Studio Code

  1. Right-click in the editor and from the context menu choose CodeMaker AI > Replace > Documentation.

Replacing documentation using JetBrains IDE

  1. Right-click in the editor and from the context menu choose CodeMaker AI > Replace > Documentation.

Replacing documentation using CodeMaker CLI

  1. Executed command in the terminal: codemaker generate docs --replace=true **/PaymentDao.java

Last updated