daizutabi / pheasant Goto Github PK
View Code? Open in Web Editor NEWDocumentation tool for Markdown conversion by Jupyter client
Home Page: https://pheasant.daizutabi.net/
License: MIT License
Documentation tool for Markdown conversion by Jupyter client
Home Page: https://pheasant.daizutabi.net/
License: MIT License
Is it possible just to run python in md-file within the brackets {{ }}?
Is it possible to avoid numbering headers and changing naming in the navigation?
plugins: - pheasant: header: disabled: true
does not lead to the desired output.
Thanks.
I noticed that for inline code having a python comment inside the fenced code block raises an Exception. For example
```python inline
a = 1
#Test comment
print(a)
```
gives the following error:
[E 191125 18:22:59 ioloop:909] Exception in callback <bound method LiveReloadHandler.poll_tasks of <class 'livereload.handlers.LiveReloadHandler'>>
Traceback (most recent call last):
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/tornado/ioloop.py", line 907, in _run
return self.callback()
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/livereload/handlers.py", line 69, in poll_tasks
filepath, delay = cls.watcher.examine()
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/livereload/watcher.py", line 105, in examine
func()
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 114, in builder
build(config, live_server=live_server, dirty=dirty)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/mkdocs/commands/build.py", line 270, in build
nav = config['plugins'].run_event('nav', nav, config=config, files=files)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/plugins/mkdocs.py", line 89, in on_nav
self.converter.convert_from_files(paths)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/converter.py", line 188, in convert_from_files
return self._convert_from_files(paths)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/pheasant.py", line 63, in _convert_from_files
self.convert(path)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/converter.py", line 179, in convert
output = self._convert(path)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/pheasant.py", line 51, in _convert
return self.convert_by_name(path, "main")
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/converter.py", line 137, in convert_by_name
source = self.parse(source, name)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/converter.py", line 108, in parse
return self.parsers[name].parse(source)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/parser.py", line 62, in parse
return "".join(iterator())
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/parser.py", line 53, in iterator
cell.output = cell.parse(splitter, self)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/base.py", line 114, in parse
return "".join(self.render(splitter, parser))
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/base.py", line 111, in _render
yield from render(self.context, splitter, parser)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/core/decorator.py", line 56, in render_
yield from render(self, context, splitter, parser)
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/renderers/jupyter/jupyter.py", line 100, in render_inline_code
code, context["option"] = split_option(context["code"])
File "/home/michael/anaconda3/envs/lectures/lib/python3.8/site-packages/pheasant/renderers/jupyter/jupyter.py", line 230, in split_option
code, option = code.split("#")
ValueError: too many values to unpack (expected 2)
I was wondering if it would be possible to use the pheasant to only display the results of the exxecution of the code in the codeblock.
Currently I insert a python script to create a table based on the result of a query to a database. I would like to display the resulting table (the one within the red border in the attached image) but not the code used to create it in the page.
Would that be possible?
First of all i want to thank you for this beautiful work.
I found a strange behaviour running pheasant with mkdocs.
Because my docs get bigger and bigger i use the include option with {% link/included.md %}
for makrdown and python files as well. For the first run this works very fine, but after updating the file e.g. included.md
the included blocks don't get updated too.
What i have tested:
included.md
the wont get updated, if i make changes to the file the {% link/included.md %}
is located the update will happen. So childs
of a file wont get updatedincluded.md
the logs show, that something got updated, but the old state appear neverthelessSome infos to the system i found the bug. Nothing special, but maybe the behaviour is caused by my setup. I am running mkdocs 1.0.4 with the material theme 4.4.2. In addition to pheasant 2.2.34 i use the following plugins:
- attr_list
- codehilite:
linenums: true
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.critic
- pymdownx.details
- pymdownx.emoji:
emoji_generator: !!python/name:pymdownx.emoji.to_svg
- pymdownx.inlinehilite
- pymdownx.magiclink
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.superfences
- pymdownx.progressbar
- pymdownx.extra
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde
- admonition
- footnotes
- pymdownx.keys
- pymdownx.arithmatex
mkdocs build
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/mkdocs/main.py", line 159, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/base.py", line 197, in load_config
errors, warnings = cfg.validate()
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/base.py", line 107, in validate
run_failed, run_warnings = self._validate()
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/base.py", line 62, in _validate
self[key] = config_option.validate(value)
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/config_options.py", line 130, in validate
return self.run_validation(value)
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/config_options.py", line 591, in run_validation
plgins[item] = self.load_plugin(item, cfg)
File "/usr/local/lib/python3.6/site-packages/mkdocs/config/config_options.py", line 599, in load_plugin
Plugin = self.installed_plugins[name].load()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2318, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2324, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.6/site-packages/pheasant/plugins/mkdocs.py", line 8, in
from mkdocs.utils import markdown_extensions, string_types
ImportError: cannot import name 'string_types'
INFO - Building documentation...
INFO - [Pheasant] Converter configured.
[E 190430 12:41:12 ioloop:909] Exception in callback <bound method LiveReloadHandler.poll_tasks of <class 'livereload.handlers.LiveReloadHandler'>>
Traceback (most recent call last):
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\tornado\ioloop.py", line 907, in _run
return self.callback()
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\livereload\handlers.py", line 66, in poll_tasks
filepath, delay = cls.watcher.examine()
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\livereload\watcher.py", line 93, in examine
func()
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\commands\serve.py", line 114, in builder
build(config, live_server=live_server, dirty=dirty)
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\commands\build.py", line 240, in build
config = config['plugins'].run_event('config', config)
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\pheasant\plugins\mkdocs.py", line 46, in on_config
config["nav"] = build_nav(config["nav"], config["docs_dir"])
File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\pheasant\plugins\mkdocs.py", line 117, in build_nav
for index, entry in enumerate(nav):
TypeError: 'NoneType' object is not iterable
The bug only appears when the nav
field in my mkdocs.yml
is left empty. I always leave it empty because I prefer the default option:
default: By default nav will contain an alphanumerically sorted, nested list of all the Markdown files found within the docs_dir and its sub-directories. If none are found it will be [] (an empty list).
My site builds just fine without pheasant and the nav gets populated as it is supposed to.
minimal mkdocs.yml
file:
site_name: test
site_author: me
plugins:
- pheasant
If I add a basic nav
in the config file it works fine.
site_name: test
site_author: me
plugins:
- pheasant
nav:
- Home: index.md
I'm using python 3.8, mkdocs 1.1 and pheasant tag 2.5.4
If I try to build site for tests/docs inside pheasant source directory, it's ok:
>>> mkdocs build
INFO - [Pheasant] Converter created.
INFO - [Pheasant] Converter configured.
INFO - Cleaning site directory
INFO - Building documentation to directory: /data/pkestene/install/python/pheasant/tests/docs/site
INFO - [Pheasant] Converting 14 pages.
[12/12][=========================] [1/14]docs/index.md [23:27:00]
[08/08][=========================] [2/14]docs/main.md [23:27:00]
[10/10][=========================] [3/14]docs/test.md [23:27:00]
[01/01][=========================] [4/14]docs/conftest.py [23:27:00]
but then if I want to serve:
>>> mkdocs serve
INFO - Building documentation...
INFO - [Pheasant] Converter created.
INFO - [Pheasant] Converter configured.
INFO - Cleaning site directory
INFO - [Pheasant] Converting 14 pages.
[12/12][=========================] [1/14]docs/index.md [23:27:09]
[08/08][=========================] [2/14]docs/main.md [23:27:09]
[10/10][=========================] [3/14]docs/test.md [23:27:09]
[01/01][=========================] [4/14]docs/conftest.py [23:27:09]
INFO - [Pheasant] Conversion finished. Elapsed time: 1.75s
INFO - Documentation built in 1.83 seconds
Traceback (most recent call last):
File "/home/pkestene/local/miniconda3/envs/eclairs/bin/mkdocs", line 10, in <module>
sys.exit(cli())
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/mkdocs/__main__.py", line 140, in serve_command
serve.serve(
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 146, in serve
_livereload(host, port, config, builder, site_dir)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 76, in _livereload
server = config['plugins'].run_event('serve', server, config=config)
File "/home/pkestene/local/miniconda3/envs/eclairs/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
result = method(item, **kwargs)
TypeError: on_serve() missing 1 required positional argument: 'builder'
Shutting down kernel [python3]...Done.
I don't known if the problem is inside mkdocs itself or in pheasant. Do you have any idea ?
Hi. Thanks for this great package. It seems to work fine in most cases. However I run into some troubles trying to get a pandas dataframe displayed as a nice table under either tabs, or collapsible blocks from the Details extension with Material for mkdocs.
Here is a basic example:
`{{
import pandas as pd
tmp = pd.DataFrame([[1, 2], [3, 4]], index=list('XY'), columns=list('ab'))
}}
??? first view
{{ tmp }}
??? Second view
{{ tmp.transpose() }}
If you run this code, the tables are shown but not under the collapsible block but just below them.
In addition, if we use tmp.to_markdown(), it renders the markdown raw table output inside the collapsible block. However, if we do not indent the inline code, like this:
??? first view {{ tmp.to_markdown() }}
Then the table output is a nice looking materials table, but again, no longer under the collapsible.
Ideally, we have the nice formatted table under the collapsible, or, at least the standard table, but under the collapsible.
It is the same issue with tabbed content, just replace ??? with === for tabs and similar output behaviour. Any clues ???
The 'on_serve' method seem to be broken since mkdocs 1.2 release. As per the release notes
"The on_serve event (which receives the server object and the builder function) is affected by the server rewrite. server is now a mkdocs.livereload.LiveReloadServer instead of livereload.server.Server. The typical action that plugins can do with these is to call server.watch(some_dir, builder), which basically adds that directory to watched directories, causing the site to be rebuilt on file changes. That still works, but passing any other function to watch is deprecated and shows a warning. This 2nd parameter is already optional, and will accept only this exact builder function just for compatibility."
so I now get the error
AttributeError: 'LiveReloadServer' object has no attribute 'watcher'
I'm using mkdocs 1.1. My nav initially looks like this:
However, when I enable pheasant, it looks like this:
Here's my mkdocs.yml: https://github.com/rjsf-team/react-jsonschema-form/blob/bdf81a70fc90f0f32b8a4e3ee5d8a4b0328d817d/mkdocs.yml#L15
A simple typo observed in the docstring of get_render_name in pheasant.core.base
mattched
should be matched
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.