Skip to content

Conversation

@daexs
Copy link
Collaborator

@daexs daexs commented Oct 28, 2025

Converted the plotly.js documentation build into Mkdocs

  • Create a Mkdocs build for the plotly.js docs and reference pages, including styling.
  • Minor modification to ‎src/traces/image/attributes.js for proper Markdown rendering on plotly.py docs' function docstrings.
  • Generates HTML snippets which are then inserted into the Markdown files for examples and references.
  • Uses javascript and hljs to apply tags to code block text which code-highlight.css applies syntax highlighting. This is done because the markdown files are HTML snippets.
  • Home/Landing page is plotly/plotly.js/README.md and index pages are placed in each individual category of examples under Overview.

gvwilson and others added 30 commits August 14, 2025 11:11
-   Import Jekyll material from graphic-library-docs repository.
-   Remove (most) mentions of languages other than Python and JavaScript.
-   Add Makefile to re-run commands.
…the html snippets for each file under 'docs/tmp/'
-   Add `./Makefile` with commands to rebuild documentation using the
    commands shown below. (We'll tidy this up in the final step.)
    -   `make examples`
    -   `make reference`
    -   `make build`
-   Move scripts from `./docs/bin` to `./bin` and adjust paths in
    scripts as needed to pick up the right files and to build into
    `./tmp`.
-   Modify `./mkdocs.yml` to build from `./tmp`.
-   Modify `./.gitignore` to ignore `./tmp`.

Note that this is only a step toward the final cleaned-up version: the
next step is to move `./docs/_posts` into the root directory, then
remove `./docs` entirely and build the site into `./docs` rather than
into `./doc`.
refactor: move documentation generation into the root directory
-   and remove last vestiges of Jekyll
@daexs daexs requested a review from LiamConnors October 28, 2025 19:03
Comment on lines +5 to +6
Our JavaScript tutorials are written in HTML files in the `_posts/plotly_js` directory of this repository.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? I don't see that directory

Comment on lines +9 to +15
To quickly make a contribution to Plotly's JavaScript graphing libraries documentation, simply submit a pull request with the change you would like to suggest. This can be done using the GitHub graphical user interface at https://github.com/plotly/graphing-library-docs.

The easiest way to do this is to follow the `Edit this page on GitHub` link at the top right of the page you are interested in contributing to:

![Screen Shot 2020-01-07 at 12 45 39 PM](https://user-images.githubusercontent.com/1557650/71916356-bfe53800-314b-11ea-92b6-eb763037f6d5.png)

**You don't have to worry about breaking the site when you submit a pull request!** This is because your change will not be merged to production immediately. A Plotly team member will first perform a code review on your pull request in order to ensure that it definitely increases the health of Plotly's graphing libraries codebase.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This readme should be updated to have the new steps

docs/404.html Outdated
@@ -0,0 +1,4518 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is page used to generate what's in content and then that's used for what's in docs?
Is there a reason why we'd need to commit this generated content?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, docs used to contain different content (unsure what exactly but it was related to the old build) and is now used to hold the site contents when you run mkdocs build. There is no reason to keep the generated content, it just hasn't been removed yet after the mkdocs changes, will remove it now!

@@ -3452,7 +3444,7 @@
"valType": "number"
},
"maxheight": {
"description": "Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than or equal to 1. Default value is: 0.5 for horizontal legends; 1 for vertical legends. The minimum allowed height is 30px. For a ratio of 0.5, the legend will take up to 50% of the reference height before displaying a scrollbar. The reference height is the full layout height with the following exception: vertically oriented legends with a `yref` of `\"paper\", located to the side of the plot. In this case, the reference height is the plot height.",
"description": "Sets the max height (in px) of the legend, or max height ratio (reference height * ratio) if less than one. Default value is: 0.5 for horizontal legends; 1 for vertical legends. The minimum allowed height is 30px. For a ratio of 0.5, the legend will take up to 50% of the reference height before displaying a scrollbar. The reference height is the full layout height except for vertically oriented legends with a `yref` of `\"paper\"`, where the reference height is the plot height.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these changes be here? I see some attributes are removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LiamConnors This branch probably needs to be updated with the latest changes from master

Comment on lines 1 to 21
[project]
name = "plotly.js"
description = "Plotly JavaScript charting library"
version = "3.1.0"
requires-python = ">=3.12"
dependencies = [
"markdown",
"python-frontmatter",
"ruff"
]

[project.optional-dependencies]
dev_build = [
"mkdocs",
"mkdocs-material",
"mkdocs-gen-files",
"mkdocs-literate-nav",
"markdown-include",
"mkdocs-macros-plugin",
"mkdocs-redirects",
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the breakdown of dependencies here suggests there are dependencies for Plotly.js. But is this pyproject.toml just for the docs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Liam that pyproject.toml is a confusing file to include here since Plotly.js is not a Python project. Could the dependencies be tracked in a requirements.txt file instead, inside a docs/ subdirectory maybe? We can discuss.

Comment on lines +1 to +29
# Manage plotly.js documentation.

RUN = uv run
SCHEMA_SRC = test/plot-schema.json
HANDWRITTEN = content
TMP = tmp

EXAMPLES_DIR = ${HANDWRITTEN}/plotly_js
EXAMPLES_IN := $(shell find "${EXAMPLES_DIR}" -name '*.html')
EXAMPLES_TMP = ${TMP}/javascript
EXAMPLES_OUT = ${EXAMPLES_TMP}/axes/index.html # could be any of the generated files

REFERENCE_DIR = ${HANDWRITTEN}/reference_pages/javascript/
REFERENCE_IN := $(wildcard ${REFERENCE_DIR}/*.html)
REFERENCE_TMP = ${TMP}/reference
REFERENCE_OUT = ${REFERENCE_TMP}/bar/index.html # could be any of the generated files

DOCS_DIR=docs
DOCS_OUT=${DOCS_DIR}/sitemap.xml

## commands: show available commands
commands:
@grep -h -E '^##' ${MAKEFILE_LIST} | sed -e 's/## //g' | column -t -s ':'

## docs: rebuild full documentation in `./docs`
.PHONY: docs
docs: ${DOCS_OUT}

${DOCS_OUT}: ${EXAMPLES_OUT} ${REFERENCE_OUT}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add to the docs contributing guide on how to build the docs, and maybe a GitHub action that runs the required steps to test generating the output.

@emilykl
Copy link
Contributor

emilykl commented Nov 6, 2025

General comment on file organization: I'd like to minimize the number of files added at the top level of this repo. Ideally anything related to the docs should be contained inside a docs/ subdirectory, except for perhaps a single .md file explaining the process for building the docs.

.gitignore Outdated

tmp

docs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A directory being added by this PR should not be in the .gitignore!

Copy link
Collaborator Author

@daexs daexs Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the directory just now since it was generated content and there is no need to commit it into the repo. I kept the .gitignore as is because mkdocs will generate its site there if you run mkdocs build.

@daexs daexs self-assigned this Nov 6, 2025
@daexs daexs added feature something new P1 needed for current cycle labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature something new P1 needed for current cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants