You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To get an idea of how this idea could work in practice, I tried the experiment of writing a module that would import the applicable code of mkdocs-table-reader-plugin. It was very straightforward.
Here is the minimal code for a module (main.py in the root directory of the MkDocs project):
frommkdocs_table_reader_plugin.readersimport*defdefine_env(env):
""" This is the hook for the functions (new form) """forreaderinREADERS.values():
env.macro(reader)
It does the following: it lists all the readers, which are conveniently listed in READERS (['read_csv', 'read_table', 'read_fwf', 'read_excel', 'read_yaml', 'read_json', 'read_feather', 'read_raw']) and declares them as macros. And voilà they were imported as macros available in every markdown page! Now its even possible to add programming logic (for repetitive actions), etc..
I attached the whole Mkdocs test project (mkdocs-tables-module.zip), so that you could reproduce my experiment, if you wish. It only requires a pip-install mkdocs-macros-plugin.
I just wished to know what you think about it, and if there could be potentially workable ideas there?
keep in mindInteresting idea, keep in mind for the future
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Originally started as an issue on the relevant plugin's website (#timvink/mkdocs-table-reader-plugin/57). Please consult this issue for the follow-up.
To get an idea of how this idea could work in practice, I tried the experiment of writing a module that would import the applicable code of
mkdocs-table-reader-plugin
. It was very straightforward.Here is the minimal code for a module (
main.py
in the root directory of the MkDocs project):It does the following: it lists all the readers, which are conveniently listed in
READERS
(['read_csv', 'read_table', 'read_fwf', 'read_excel', 'read_yaml', 'read_json', 'read_feather', 'read_raw']
) and declares them as macros. And voilà they were imported as macros available in every markdown page! Now its even possible to add programming logic (for repetitive actions), etc..I attached the whole Mkdocs test project (mkdocs-tables-module.zip), so that you could reproduce my experiment, if you wish. It only requires a
pip-install mkdocs-macros-plugin
.I just wished to know what you think about it, and if there could be potentially workable ideas there?
Beta Was this translation helpful? Give feedback.
All reactions