timvink / mkdocs-table-reader-plugin

MkDocs plugin that enables a markdown tag like {{ read_csv('table.csv') }} to directly insert various table formats into a page
https://timvink.github.io/mkdocs-table-reader-plugin/
MIT License
124 stars 20 forks source link

Add `exclude` option for this plugin to skip specific files #52

Closed flynneva closed 1 year ago

flynneva commented 1 year ago

I've got a large, autogenerated .md file that I'd like this plugin to skip. Is it possible to add an attribute to the .yml settings for this plugin that allows the user to specify specific files to skip that we know do not have any tables-to-read in them?

timvink commented 1 year ago

So it's for performance reasons you want to skip it? As-in, the build time is slow?

The way I currently implemented the table reader, is using a simple regex, which is run for every available reader and on every file: https://github.com/timvink/mkdocs-table-reader-plugin/blob/d02c81c3fc17c7d992e545b6b36dbeb437b1676f/mkdocs_table_reader_plugin/plugin.py#L75-L83 I have not benchmarked this, but it's likely to be slow, especially for large files.

It might be better to solve the root issue instead. I am planning to add a superfence notation (https://github.com/timvink/mkdocs-table-reader-plugin/issues/45), which should but a lot faster (I have not benchmarked this either).

If the superfence notation is much faster, adding an option to disable the regex syntax would be the better solution. We could given write a little python scripts to help migration: it should replace the regex syntax with the superfence notation in all markdown files.

flynneva commented 1 year ago

@timvink sorry I think I should've reworded the original issue.

I've got a lot of autogenerated .md files (api-reference documentation and some others) that I know do not use this plugin at all in them.

So I'd like to exclude / skip them, does that make sense?

timvink commented 1 year ago

Not really :)

Why would you want to exclude them if the documentation build time is not an issue?

timvink commented 1 year ago

Btw, plugins are executed in order of appearance in your mkdocs file (unless they use the priority system of mkdocs). Moving this plugin higher up in your mkdocs.yml plugins section might already do what you want. But again, I don't understand yet what you are trying to achieve

timvink commented 1 year ago

I was really curious about the performance of this page, so I wrote a little benchmark script (https://github.com/timvink/mkdocs-table-reader-plugin/commit/931acb83a53b3bc59ae80181b33d11bb996aa9bd).

A markdown file with 100k lines of random text (~10Mb) builds within 5 seconds. That seems very reasonable actually.

Maybe my benchmark is wrong, or your site is huge, but I'm guessing performance is not the issue?

timvink commented 1 year ago

Revisiting this and extended the benchmark a bit:

Mkdocs build completed, using a page with size 97M. Elapsed time: 1 mins 6 secs
Mkdocs build (no table-reader) completed, using a page with size 97M. Elapsed time: 0 mins 48 secs
Mkdocs build (superfences extension enabled) completed, using a page with size 97M. . Elapsed time: 0 mins 51 secs

So for a 100Mb file,

flynneva commented 1 year ago

@timvink this issue can be closed - no worries! Thanks for digging into it