langchain/docs
Really Him fbd2e10703
docs: hide jsx in llm chain tutorial (#30187)
## **Description:** 
The Jupyter notebooks in the docs section are extremely useful and
critical for widespread adoption of LangChain amongst new developers.
However, because they are also converted to MDX and used to build the
HTML for the Docusaurus site, they contain JSX code that degrades
readability when opened in a "notebook" setting (local notebook server,
google colab, etc.). For instance, here we see the website, with a nice
React tab component for installation instructions (`pip` vs `conda`):

![Screenshot 2025-03-07 at 2 07
15 PM](https://github.com/user-attachments/assets/a528d618-f5a0-4d2e-9aed-16d4b8148b5a)

Now, here is the same notebook viewed in colab:

![Screenshot 2025-03-07 at 2 08
41 PM](https://github.com/user-attachments/assets/87acf5b7-a3e0-46ac-8126-6cac6eb93586)

Note that the text following "To install LangChain run:" contains
snippets of JSX code that is (i) confusing, (ii) bad for readability,
(iii) potentially misleading for a novice developer, who might take it
literally to mean that "to install LangChain I should run `import Tabs
from...`" and then an ill-formed command which mixes the `pip` and
`conda` installation instructions.

Ideally, we would like to have a system that presents a
similar/equivalent UI when viewing the notebooks on the documentation
site, or when interacting with them in a notebook setting - or, at a
minimum, we should not present ill-formed JSX snippets to someone trying
to execute the notebooks. As the documentation itself states, running
the notebooks yourself is a great way to learn the tools. Therefore,
these distracting and ill-formed snippets are contrary to that goal.

## **Fixes:**
* Comment out the JSX code inside the notebook
`docs/tutorials/llm_chain` with a special directive `<!-- HIDE_IN_NB`
(closed with `HIDE_IN_NB -->`). This makes the JSX code "invisible" when
viewed in a notebook setting.
* Add a custom preprocessor that runs process_cell and just erases these
comment strings. This makes sure they are rendered when converted to
MDX.
* Minor tweak: Refactor some of the Markdown instructions into an
executable codeblock for better experience when running as a notebook.
* Minor tweak: Optionally try to get the environment variables from a
`.env` file in the repo so the user doesn't have to enter it every time.
Depends on the user installing `python-dotenv` and adding their own
`.env` file.
* Add an environment variable for "LANGSMITH_PROJECT"
(default="default"), per the LangSmith docs, so a local user can target
a specific project in their LangSmith account.

**NOTE:** If this PR is approved, and the maintainers agree with the
general goal of aligning the notebook execution experience and the doc
site UI, I would plan to implement this on the rest of the JSX snippets
that are littered in the notebooks.

**NOTE:** I wasn't able to/don't know how to run the linkcheck Makefile
commands.

- [X] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

---------

Co-authored-by: Really Him <hesereallyhim@proton.me>
2025-03-26 14:22:33 -04:00
..
api_reference docs: sidebar-content-render (#30061) (#30062) 2025-03-01 15:30:41 -05:00
cassettes docs: update cassettes (#30434) 2025-03-22 12:57:36 -04:00
data docs: 👥 Update LangChain people data (#27022) 2024-10-08 17:09:07 +00:00
docs docs: hide jsx in llm chain tutorial (#30187) 2025-03-26 14:22:33 -04:00
scripts docs: hide jsx in llm chain tutorial (#30187) 2025-03-26 14:22:33 -04:00
src docs: Update VectorStoreTab vector store initializations (#30413) 2025-03-22 17:29:45 -04:00
static docs: update readme (#30239) 2025-03-12 13:45:13 -04:00
.gitignore infra: cleanup docs build (#21134) 2024-05-01 17:34:05 -07:00
.yarnrc.yml
babel.config.js
docusaurus.config.js Banner for interrupt (#29567) 2025-02-03 17:40:24 -08:00
ignore-step.sh infra: run docs build on packages.yml updates (#29796) 2025-02-19 18:45:30 +00:00
Makefile docs: fix httpx conflicts with overrides in docs build (#29180) 2025-01-13 21:25:00 +00:00
package.json docs: raw loader codeblock (#28548) 2024-12-06 09:26:34 -08:00
README.md docs: reorganize contributing docs (#27649) 2024-10-25 22:41:54 +00:00
sidebars.js docs: reorg sidebar (#27978) 2024-11-15 14:28:18 -08:00
vercel_overrides.txt docs: add to vercel overrides (#30063) 2025-03-01 17:21:15 -05:00
vercel_requirements.txt docs: more useful vercel warnings (#28699) 2024-12-13 03:07:24 +00:00
vercel.json docs: tests/standard tests api ref redirect (#29444) 2025-01-27 23:21:50 -08:00
yarn.lock docs: raw loader codeblock (#28548) 2024-12-06 09:26:34 -08:00

LangChain Documentation

For more information on contributing to our documentation, see the Documentation Contributing Guide