Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various documentation fixes before 1.5.0 RC2 #7246

Merged
merged 47 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d32f40a
Disable gallery thumbnail auto-generation
philippjfr Sep 9, 2024
acf9213
Drop comms doc from toctree
philippjfr Sep 9, 2024
79b8d19
Fix PyComponent docs examples
philippjfr Sep 9, 2024
8ab46ab
Disable fork safety when building docs on OSX
philippjfr Sep 9, 2024
55bf26d
Add copybutton after pyodide
philippjfr Sep 9, 2024
f54a57b
Handle ipywidget kernel registration differently
philippjfr Sep 9, 2024
f17dbf4
Update pygment theme variables
philippjfr Sep 10, 2024
8852c85
Fix mocked session_context on convert
philippjfr Sep 10, 2024
2835476
Attempt with nbsite parallel branch
philippjfr Sep 10, 2024
2703f8d
Fix git url
philippjfr Sep 10, 2024
2a6394e
Another attempt
philippjfr Sep 10, 2024
6d4a38a
And another
philippjfr Sep 10, 2024
39ff15b
Use pypi-deps
philippjfr Sep 10, 2024
49b19a0
Undo change to datetime utility
philippjfr Sep 10, 2024
24d0e45
Drop inheritance diagrams
philippjfr Sep 10, 2024
fb15577
Drop mystnb extension
philippjfr Sep 10, 2024
c5cc011
Add myst-parser
philippjfr Sep 10, 2024
205e94b
Configure mystnb_config
philippjfr Sep 10, 2024
a449613
Remove Streamz reference doc
philippjfr Sep 10, 2024
cc8abb2
Bump nbsite version
philippjfr Sep 10, 2024
df1dc02
Clean up pre-rendered views in pyodide
philippjfr Sep 10, 2024
45ea93e
Revert "Remove Streamz reference doc"
philippjfr Sep 10, 2024
aa3e77a
Bump nbsite
philippjfr Sep 10, 2024
0359629
Fix MockSessionContext
philippjfr Sep 10, 2024
bb4cfd4
Bump nbsite
philippjfr Sep 10, 2024
ce5ce48
Bump nbsite
philippjfr Sep 10, 2024
a3646d4
Bump nbsite
philippjfr Sep 10, 2024
c80a1fa
Move comms into architecture section
philippjfr Sep 10, 2024
7dc1421
Show only df.head() in penguin_crossfilter
philippjfr Sep 10, 2024
1fa26e6
Bump nbsite
philippjfr Sep 10, 2024
a941cad
Bump nbsite
philippjfr Sep 10, 2024
9dee595
Add verbose
philippjfr Sep 10, 2024
cc70f1e
Reduce verbosity
philippjfr Sep 10, 2024
1cc5c98
Fix pyodide buttons
philippjfr Sep 10, 2024
bbb0e3e
Ensure homepage example renders
philippjfr Sep 11, 2024
5b725be
Increase verbosity again
philippjfr Sep 10, 2024
938c145
Do not cache opaque responses
philippjfr Sep 11, 2024
29dfc47
Rename Comms docs
philippjfr Sep 11, 2024
8f2c1c5
Re-enable verbosity
philippjfr Sep 11, 2024
e028586
Latest nbsite
philippjfr Sep 12, 2024
2ad01d3
Add nbsite with flush
philippjfr Sep 12, 2024
b3cb73f
Update pixi.toml
philippjfr Sep 12, 2024
1fa2f08
Update pixi.toml
philippjfr Sep 12, 2024
9a9c5eb
Add parallel doc build target
philippjfr Sep 12, 2024
953b99e
Use nbsite dev release
philippjfr Sep 12, 2024
88d69ce
Fix indentation
philippjfr Sep 12, 2024
79fbc13
Merge branch 'main' into doc_fixes_1.5.0_rc2
philippjfr Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import pathlib

from typing import Any

import param

param.parameterized.docstring_signature = False
Expand Down Expand Up @@ -71,8 +73,8 @@
"icon": "fa-brands fa-discord",
},
],
"pygment_light_style": "material",
"pygment_dark_style": "material",
"pygments_light_style": "material",
"pygments_dark_style": "material",
"header_links_before_dropdown": 5,
'secondary_sidebar_items': [
"github-stars-button",
Expand All @@ -82,15 +84,27 @@
"announcement": announcement_text,
}

extensions += [
'sphinx.ext.napoleon',
'nbsite.gallery',

extensions = [
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
'myst_parser',
'sphinx_design',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.linkcode',
'sphinx_copybutton',
'sphinxext.rediraffe',
'nbsite.gallery',
'nbsite.pyodide',
'nbsite.analytics',
]
napoleon_numpy_docstring = True

autodoc_mock_imports = ["panel.pane.vtk"]

myst_enable_extensions = ["colon_fence", "deflist"]

gallery_endpoint = 'panel-gallery-dev' if is_dev else 'panel-gallery'
Expand Down Expand Up @@ -137,12 +151,13 @@
'PanelCallbackHandler': 'LangChain CallbackHandler',
},
'as_pyodide': True,
'normalize_titles': False
'normalize_titles': False,
}
},
'thumbnail_url': 'https://assets.holoviz.org/panel/thumbnails',
'deployment_url': gallery_url,
'jupyterlite_url': jlite_url,
'only_use_existing': True,
}

if panel.__version__ != version and (PANEL_ROOT / 'dist' / 'wheels').is_dir():
Expand Down Expand Up @@ -257,6 +272,37 @@ def update_versions(app, docname, source):
source[0] = source[0].replace(old, new)


def setup_mystnb(app):
from myst_nb.core.config import NbParserConfig
from myst_nb.sphinx_ import (
HideCodeCellNode, HideInputCells, SelectMimeType,
)
from myst_nb.sphinx_ext import create_mystnb_config

_UNSET = "--unset--"
for name, default, field in NbParserConfig().as_triple():
if not field.metadata.get("sphinx_exclude"):
# TODO add types?
app.add_config_value(f"nb_{name}", default, "env", Any) # type: ignore[arg-type]
if "legacy_name" in field.metadata:
app.add_config_value(
f"{field.metadata['legacy_name']}",
_UNSET,
"env",
Any, # type: ignore[arg-type]
)
app.add_config_value("nb_render_priority", _UNSET, "env", Any) # type: ignore[arg-type]
create_mystnb_config(app)

# add post-transform for selecting mime type from a bundle
app.add_post_transform(SelectMimeType)

# setup collapsible content
app.add_post_transform(HideInputCells)
HideCodeCellNode.add_to_app(app)



def setup(app) -> None:
try:
from nbsite.paramdoc import param_formatter, param_skip
Expand All @@ -265,6 +311,8 @@ def setup(app) -> None:
except ImportError:
print('no param_formatter (no param?)')

app.connect('builder-inited', setup_mystnb)

app.connect('source-read', update_versions)
nbbuild.setup(app)
app.add_config_value('grid_item_link_domain', '', 'html')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Panel + Juypter, Servers, etc.
# Communication Channels

Panel lets you write Python code that corresponds to Javascript/HTML objects in a web browser, which requires some means of communication between the two languages. How this communication is achieved depends on the context in which Panel is used, i.e., whether it is being run in a notebook like Classic Jupyter, in JupyterLab, as a standalone web server, etc. Usually it all Just Works™, but in case it doesn't, or if you want to understand the details or limitations of a particular configuration, this page will explain which technologies are used in which contexts to achieve the required channels of communication.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. raw:: html
<head>
<meta http-equiv='refresh' content='0; URL=./index.html#linking'>
<meta http-equiv='refresh' content='0; URL=./index.html#architecture>
</head>

# Linking
# Architecture

```{toctree}
:titlesonly:
:hidden:
:maxdepth: 1

Panel and JS communications <comms/comms>
Communication Channels <comms>
```
7 changes: 3 additions & 4 deletions doc/explanation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ Deepen your understanding about custom `ReactiveHTML` components

::::

## Linking
## Architecture

::::{grid} 1 2 2 3
:gutter: 1 1 1 2

:::{grid-item-card} {octicon}`arrow-both;2.5em;sd-mr-1 sd-animate-grow50` Panel Communications
:link: comms
:link: architecture/comms
:link-type: doc

Deepen your understanding about how Panel communicates between Python and Javascript in different contexts.
Expand Down Expand Up @@ -292,8 +292,7 @@ Learn about why and how Panel utilizes the Bokeh library.
develop_seamlessly
apis
components
linking
comms
architecture
styling
dependencies
comparisons
Expand Down
7 changes: 0 additions & 7 deletions doc/generate_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,10 @@ def format_directive(module, package=None):
directive += ' :%s:\n' % option
return directive

def format_inheritance_diagram(module, package=None):
"""Create the inheritance_diagram directive and add the options."""
directive = '.. inheritance-diagram:: %s\n' % makename(package, module)
return directive

def create_module_file(package, module, opts):
"""Build the text of the file and write the file."""

text = format_heading(1, '%s Module' % module)
text += format_inheritance_diagram(package, module)
text += format_heading(2, ':mod:`%s` Module' % module)
text += format_directive(module, package)
write_file(makename(package, module), text, opts)
Expand All @@ -109,7 +103,6 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs):
else:
heading = ':mod:`%s` Module' % py_file
text += format_heading(2, heading)
text += format_inheritance_diagram(is_package and subroot or py_path, master_package)
text += '\n\n'
text += format_directive(is_package and subroot or py_path, master_package)
text += '\n-------\n\n'
Expand Down
18 changes: 9 additions & 9 deletions doc/how_to/custom_components/examples/esm_material_ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class Rating(MaterialComponent):
_esm = """
import Rating from '@mui/material/Rating'

export function render({model}) {
export function render({model}) {
const [value, setValue] = model.useState("value")
return (
<Rating
value={value}
<Rating
value={value}
onChange={(event, newValue) => setValue(newValue) }
/>
)
}
"""
)
}
"""

class DiscreteSlider(MaterialComponent):

Expand All @@ -88,7 +88,7 @@ class DiscreteSlider(MaterialComponent):
aria-label="Restricted values"
defaultValue={value}
marks={marks}
onChange={(e) => setValue(e.target.value)}
onChange={(e) => setValue(e.target.value)}
step={null}
valueLabelDisplay="auto"
/>
Expand All @@ -103,7 +103,7 @@ slider = DiscreteSlider()

pn.Row(
pn.Column(button.controls(['disabled', 'label', 'variant']), button),
pn.Column(rating.controls(['value']), rating),
pn.Column(slider.controls(['value']), slider),
pn.Column(rating.controls(['value']), rating),
pn.Column(slider.controls(['value']), slider),
).servable()
```
4 changes: 2 additions & 2 deletions doc/how_to/custom_components/python/create_custom_widget.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class FeatureInput(WidgetBase, PyComponent):

super().__init__(**params)

selected_features_widget = pn.widgets.MultiChoice.from_param(
self._selected_features_widget = pn.widgets.MultiChoice.from_param(
self.param.selected_features, sizing_mode="stretch_width"
)

def __panel__(self):
return pn.Column(selected_features_widget, self._selected_widgets)
return pn.Column(self._selected_features_widget, self._selected_widgets)

@param.depends("features", watch=True, on_init=True)
def _reset_selected_features(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/penguin_crossfilter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"penguins = pd.read_csv('https://datasets.holoviz.org/penguins/v1/penguins.csv')\n",
"penguins = penguins[~penguins.sex.isnull()].reset_index().sort_values('species')\n",
"\n",
"penguins"
"penguins.head()"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions panel/_templates/pyodide_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ pyodideWorker.onmessage = async (event) => {
render_items[0]['roots'] = roots
render_items[0]['root_ids'] = root_ids

// Clear pre-rendered contents
Bokeh.index.roots.map((v) => v.remove())

// Embed content
const [views] = await Bokeh.embed.embed_items(docs_json, render_items)

Expand Down
1 change: 1 addition & 0 deletions panel/dist/css/chat_message.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@

.divider {
margin-right: 0px;
margin-top: 2px;
opacity: 0.2;
}

Expand Down
29 changes: 1 addition & 28 deletions panel/io/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import base64
import concurrent.futures
import dataclasses
import json
import os
import pathlib
Expand All @@ -12,7 +11,6 @@

import bokeh

from bokeh.application.application import SessionContext
from bokeh.application.handlers.code import CodeHandler
from bokeh.core.json_encoder import serialize_json
from bokeh.core.templates import FILE, MACROS, get_env
Expand All @@ -25,6 +23,7 @@
from .. import __version__, config
from ..util import base_version, escape
from .application import Application, build_single_handler_application
from .document import MockSessionContext
from .loading import LOADING_INDICATOR_CSS_CLASS
from .mime_render import find_requirements
from .resources import (
Expand Down Expand Up @@ -121,32 +120,6 @@
</script>
"""

@dataclasses.dataclass
class Request:
headers : dict
cookies : dict
arguments : dict


class MockSessionContext(SessionContext):

def __init__(self, *args, document=None, **kwargs):
self._document = document
super().__init__(*args, server_context=None, session_id=None, **kwargs)

def with_locked_document(self, *args):
return

@property
def destroyed(self) -> bool:
return False

@property
def request(self):
return Request(headers={}, cookies={}, arguments={})



def make_index(files, title=None, manifest=True):
if manifest:
manifest = 'site.webmanifest'
Expand Down
4 changes: 4 additions & 0 deletions panel/io/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def __init__(self, *args, document=None, **kwargs):
def with_locked_document(self, *args):
return

@property
def session(self):
return None

@property
def destroyed(self) -> bool:
return False
Expand Down
2 changes: 1 addition & 1 deletion panel/io/ipywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def _on_widget_constructed(widget, doc=None):
if widget._model_id is not None:
args['comm_id'] = widget._model_id
try:
_IPyComm.kernel = kernel
widget.comm = _IPyComm(**args)
widget.comm.kernel = kernel
except Exception as e:
if 'PANEL_IPYWIDGET' not in os.environ:
raise e
Expand Down
15 changes: 13 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,18 @@ test-type = 'mypy panel'
[feature.doc.activation.env]
MOZ_HEADLESS = "1"
PANEL_IPYWIDGET = "1"
OBJC_DISABLE_INITIALIZE_FORK_SAFETY = "YES"
philippjfr marked this conversation as resolved.
Show resolved Hide resolved

[feature.doc.dependencies]
lxml = "*"
nbsite = ">=0.8.4"
nbsite = ">=0.8.6rc1"
selenium = "*"

[feature.doc.tasks]
_docs-refmanual = 'python ./doc/generate_modules.py panel -d ./doc/api -n panel -e tests'
_docs-convert-gallery = 'python scripts/gallery/convert_gallery.py'
_docs-generate = 'nbsite build --what=html --output=builtdocs --org holoviz --project-name panel'
_docs-generate = 'nbsite build --what=html --output=builtdocs --org holoviz --project-name panel --disable-parallel'
_docs-generate-parallel = 'nbsite build --what=html --output=builtdocs --org holoviz --project-name panel'
_docs-copy-panel-dist = 'cp -r ./panel/dist ./builtdocs/panel_dist'
_docs-pyodide = 'panel convert examples/gallery/*.ipynb doc/how_to/*/examples/*.md --to pyodide-worker --out ./builtdocs/pyodide/ --pwa --index --requirements doc/pyodide_dependencies.json --exclude examples/gallery/vtk*.ipynb'
docs-server = 'python -m http.server 5500 --directory ./builtdocs'
Expand All @@ -200,6 +202,15 @@ depends_on = [
'_docs-pyodide',
]

[feature.doc.tasks.docs-build-parallel]
depends_on = [
'_docs-refmanual',
'_docs-convert-gallery',
'_docs-generate-parallel',
'_docs-copy-panel-dist',
'_docs-pyodide',
]

# =============================================
# ================== BUILD ====================
# =============================================
Expand Down
Loading