Giter Club home page Giter Club logo

pheasant's People

Contributors

daizutabi avatar pkestene avatar timgates42 avatar timvink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pheasant's Issues

mkdocs fails to build documentation with pheasant if 'nav' isn't specified

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

Included other markdown or python files dont get updated

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:

  • The directory is not relevant. A markdown file located in the docs directory directly have the same issue
  • If i make change to 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 updated
  • if i restart mkdocs, everthing working fine
  • after changing included.md the logs show, that something got updated, but the old state appear nevertheless

Some 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

pheasant use string_types which is not provided by mkdocs

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'

Pheasant and tabbed extension

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'))
}}

Table

??? first view
{{ tmp }}

??? Second view
{{ tmp.transpose() }}

Rest of document`

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 ???

mkdocs with pheasant builds fine but can't serve

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 ?

LiveReloadServer object has no attribute 'watcher'

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'

Just run python withiin brackets

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.

Display only the results

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?

Image example:
query

Comment in python inline code leads to problem

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.