backstage/mkdocs-monorepo-plugin

Check whether the page source is in this plugins control

Closed this issue · 0 comments

If another plugin modifies the sources, it's not always true that this plugins files_source_dir dict will always contain the page.file.abs_src_path, and therefore this might throw an error:

From

page.file.abs_src_path = self.files_source_dir[page.file.abs_src_path]

    def on_pre_page(self, page, config, files):
        # Update page source attribute to point to source file
        # Only in case any files were moved.
        if len(self.files_source_dir) > 0:
            page.file.abs_src_path = self.files_source_dir[page.file.abs_src_path]
        return page

This code should check whether it was "managing" the source for the page via

 if len(self.files_source_dir) > 0 && page.file.abs_src_path in self.files_source_dir:

before trying to change it (at Line 62 of plugin.py)