Skip to the content.

Copy Contents Plugin

Back to Index

Copies the entire contents of specified files into the documentation. This is useful for including external files like README files, configuration examples, or other documentation files.

import { CopyContentsPlugin } from 'simple-docs-scraper/extractors';

const extractor = new CopyContentsPlugin({
  fileToCopy: 'README.md',
  searchAndReplace: '%readme%'
});

Configuration:

Example usage:

// Single file
const extractor = new CopyContentsPlugin({
  fileToCopy: 'docs/installation.md',
  searchAndReplace: '%installation%'
});

// Multiple files
const extractor = new CopyContentsPlugin({
  fileToCopy: ['README.md', 'CHANGELOG.md', 'LICENSE'],
  searchAndReplace: '%project-files%'
});

Error handling: The plugin will return an error if any of the specified files cannot be found:

{
  errorMessage: "Unable to copy file contents. File 'missing-file.md' not found",
  throwable: true
}