public DocumentRenderingContext()

in doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderingContext.java [96:136]


    public DocumentRenderingContext(
            File basedir,
            String basedirRelativePath,
            String document,
            String parserId,
            String extension,
            boolean editable,
            String generator) {
        this.basedir = basedir;
        this.parserId = parserId;
        this.extension = extension;
        this.generator = generator;
        this.attributes = new HashMap<>();

        document = document.replace('\\', '/');
        this.inputPath = document;

        if (extension != null && !extension.isEmpty()) {
            this.basedirRelativePath = basedirRelativePath.replace('\\', '/');
            // document comes from a Doxia source: see DoxiaDocumentRenderer
            this.editable = editable;

            // here we know the parserId and extension, we can play with this to get output name from document:
            // - index.xml -> index.html
            // - index.xml.vm -> index.html
            // - download.apt.vm --> download.html
            if (DefaultSiteRenderer.endsWithIgnoreCase(document, ".vm")) {
                document = document.substring(0, document.length() - 3);
            }
            String filePathWithoutExt = document.substring(0, document.length() - extension.length() - 1);
            this.outputPath = filePathWithoutExt + ".html";
        } else {
            // document does not come from a Doxia source but direct Sink API, so no file extension to strip
            this.basedirRelativePath = null;
            this.editable = false;
            this.outputPath = document + ".html";
        }

        this.relativePath = PathTool.getRelativePath(basedir.getPath(), new File(basedir, inputPath).getPath())
                .replace('\\', '/');
    }