Skip to content

Commit 5bea283

Browse files
authored
docs: standardize .. code-block directive usage (#33122)
and fix typos
1 parent c3fed20 commit 5bea283

File tree

24 files changed

+103
-119
lines changed

24 files changed

+103
-119
lines changed

docs/api_reference/_extensions/gallery_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class GalleryGridDirective(SphinxDirective):
5050
individual cards + ["image", "header", "content", "title"].
5151
5252
Danger:
53-
This directive can only be used in the context of a Myst documentation page as
53+
This directive can only be used in the context of a MyST documentation page as
5454
the templates use Markdown flavored formatting.
5555
"""
5656

docs/api_reference/conf.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def skip_private_members(app, what, name, obj, skip, options):
126126
"sphinx.ext.viewcode",
127127
"sphinxcontrib.autodoc_pydantic",
128128
"IPython.sphinxext.ipython_console_highlighting",
129-
"myst_parser",
129+
"myst_parser", # For generated index.md and reference.md
130130
"_extensions.gallery_directive",
131131
"sphinx_design",
132132
"sphinx_copybutton",
@@ -259,20 +259,8 @@ def skip_private_members(app, what, name, obj, skip, options):
259259
html_css_files = ["css/custom.css"]
260260
html_use_index = False
261261

262-
myst_enable_extensions = [
263-
"colon_fence", # ::: directive blocks (existing prior to LangGraph support)
264-
# LangGraph compatibility extensions added for consolidation
265-
# TODO: check for presence of each in LangGraph and only enable if needed
266-
# "deflist", # Definition lists
267-
# "tasklist", # - [ ] checkboxes (common in examples)
268-
# "attrs_inline", # {.class} inline attributes (MkDocs style)
269-
# "attrs_block", # Block-level attributes
270-
# "substitution", # Variable substitution
271-
# "linkify", # Auto-link URLs in text
272-
# Math extensions (uncomment if LangGraph uses mathematical notation)
273-
# "dollarmath", # $ math $ inline math
274-
# "amsmath", # Advanced math environments
275-
]
262+
# Only used on the generated index.md and reference.md files
263+
myst_enable_extensions = ["colon_fence"]
276264

277265
# generate autosummary even if no references
278266
autosummary_generate = True

docs/api_reference/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sphinx-copybutton
66
sphinxcontrib-googleanalytics
77
pydata-sphinx-theme>=0.15
88
myst-parser>=3
9-
toml>=0.10.2
109
myst-nb>=1.1.1
10+
toml>=0.10.2
1111
pyyaml
1212
beautifulsoup4

libs/cli/langchain_cli/integration_template/integration_template/retrievers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class __ModuleName__Retriever(BaseRetriever):
4646
4747
retriever.invoke(query)
4848
49-
.. code-block:: none
49+
.. code-block::
5050
5151
# TODO: Example output.
5252
@@ -80,7 +80,7 @@ def format_docs(docs):
8080
8181
chain.invoke("...")
8282
83-
.. code-block:: none
83+
.. code-block::
8484
8585
# TODO: Example output.
8686

libs/cli/langchain_cli/integration_template/integration_template/toolkits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class __ModuleName__Toolkit(BaseToolkit):
4242
4343
toolkit.get_tools()
4444
45-
.. code-block:: none
45+
.. code-block::
4646
4747
# TODO: Example output.
4848
@@ -62,7 +62,7 @@ class __ModuleName__Toolkit(BaseToolkit):
6262
for event in events:
6363
event["messages"][-1].pretty_print()
6464
65-
.. code-block:: none
65+
.. code-block::
6666
6767
# TODO: Example output.
6868

libs/core/langchain_core/callbacks/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def trace_as_chain_group(
9292
metadata (dict[str, Any], optional): The metadata to apply to all runs.
9393
Defaults to None.
9494
95-
.. note:
95+
.. note::
9696
Must have ``LANGCHAIN_TRACING_V2`` env var set to true to see the trace in
9797
LangSmith.
9898
@@ -179,7 +179,7 @@ async def atrace_as_chain_group(
179179
Yields:
180180
The async callback manager for the chain group.
181181
182-
.. note:
182+
.. note::
183183
Must have ``LANGCHAIN_TRACING_V2`` env var set to true to see the trace in
184184
LangSmith.
185185

libs/core/langchain_core/callbacks/usage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UsageMetadataCallbackHandler(BaseCallbackHandler):
3232
result_2 = llm_2.invoke("Hello", config={"callbacks": [callback]})
3333
callback.usage_metadata
3434
35-
.. code-block:: none
35+
.. code-block::
3636
3737
{'gpt-4o-mini-2024-07-18': {'input_tokens': 8,
3838
'output_tokens': 10,
@@ -119,7 +119,7 @@ def get_usage_metadata_callback(
119119
llm_2.invoke("Hello")
120120
print(cb.usage_metadata)
121121
122-
.. code-block:: none
122+
.. code-block::
123123
124124
{'gpt-4o-mini-2024-07-18': {'input_tokens': 8,
125125
'output_tokens': 10,

libs/core/langchain_core/document_loaders/langsmith.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class LangSmithLoader(BaseLoader):
3131
for doc in loader.lazy_load():
3232
docs.append(doc)
3333
34-
.. code-block:: pycon
34+
.. code-block:: python
3535
3636
# -> [Document("...", metadata={"inputs": {...}, "outputs": {...}, ...}), ...]
3737

libs/core/langchain_core/indexing/api.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ def index(
296296
For the time being, documents are indexed using their hashes, and users
297297
are not able to specify the uid of the document.
298298
299-
Important:
299+
.. versionchanged:: 0.3.25
300+
Added ``scoped_full`` cleanup mode.
301+
302+
.. important::
303+
300304
* In full mode, the loader should be returning
301305
the entire dataset, and not just a subset of the dataset.
302306
Otherwise, the auto_cleanup will remove documents that it is not
@@ -309,7 +313,7 @@ def index(
309313
chunks, and we index them using a batch size of 5, we'll have 3 batches
310314
all with the same source id. In general, to avoid doing too much
311315
redundant work select as big a batch size as possible.
312-
* The `scoped_full` mode is suitable if determining an appropriate batch size
316+
* The ``scoped_full`` mode is suitable if determining an appropriate batch size
313317
is challenging or if your data loader cannot return the entire dataset at
314318
once. This mode keeps track of source IDs in memory, which should be fine
315319
for most use cases. If your dataset is large (10M+ docs), you will likely
@@ -378,10 +382,6 @@ def index(
378382
TypeError: If ``vectorstore`` is not a VectorStore or a DocumentIndex.
379383
AssertionError: If ``source_id`` is None when cleanup mode is incremental.
380384
(should be unreachable code).
381-
382-
.. version_modified:: 0.3.25
383-
384-
* Added `scoped_full` cleanup mode.
385385
"""
386386
# Behavior is deprecated, but we keep it for backwards compatibility.
387387
# # Warn only once per process.
@@ -636,26 +636,30 @@ async def aindex(
636636
documents were deleted, which documents should be skipped.
637637
638638
For the time being, documents are indexed using their hashes, and users
639-
are not able to specify the uid of the document.
640-
641-
Important:
642-
* In full mode, the loader should be returning
643-
the entire dataset, and not just a subset of the dataset.
644-
Otherwise, the auto_cleanup will remove documents that it is not
645-
supposed to.
646-
* In incremental mode, if documents associated with a particular
647-
source id appear across different batches, the indexing API
648-
will do some redundant work. This will still result in the
649-
correct end state of the index, but will unfortunately not be
650-
100% efficient. For example, if a given document is split into 15
651-
chunks, and we index them using a batch size of 5, we'll have 3 batches
652-
all with the same source id. In general, to avoid doing too much
653-
redundant work select as big a batch size as possible.
654-
* The `scoped_full` mode is suitable if determining an appropriate batch size
655-
is challenging or if your data loader cannot return the entire dataset at
656-
once. This mode keeps track of source IDs in memory, which should be fine
657-
for most use cases. If your dataset is large (10M+ docs), you will likely
658-
need to parallelize the indexing process regardless.
639+
are not able to specify the uid of the document.
640+
641+
.. versionchanged:: 0.3.25
642+
Added ``scoped_full`` cleanup mode.
643+
644+
.. important::
645+
646+
* In full mode, the loader should be returning
647+
the entire dataset, and not just a subset of the dataset.
648+
Otherwise, the auto_cleanup will remove documents that it is not
649+
supposed to.
650+
* In incremental mode, if documents associated with a particular
651+
source id appear across different batches, the indexing API
652+
will do some redundant work. This will still result in the
653+
correct end state of the index, but will unfortunately not be
654+
100% efficient. For example, if a given document is split into 15
655+
chunks, and we index them using a batch size of 5, we'll have 3 batches
656+
all with the same source id. In general, to avoid doing too much
657+
redundant work select as big a batch size as possible.
658+
* The ``scoped_full`` mode is suitable if determining an appropriate batch size
659+
is challenging or if your data loader cannot return the entire dataset at
660+
once. This mode keeps track of source IDs in memory, which should be fine
661+
for most use cases. If your dataset is large (10M+ docs), you will likely
662+
need to parallelize the indexing process regardless.
659663
660664
Args:
661665
docs_source: Data loader or iterable of documents to index.
@@ -720,10 +724,6 @@ async def aindex(
720724
TypeError: If ``vector_store`` is not a VectorStore or DocumentIndex.
721725
AssertionError: If ``source_id_key`` is None when cleanup mode is
722726
incremental or ``scoped_full`` (should be unreachable).
723-
724-
.. version_modified:: 0.3.25
725-
726-
* Added `scoped_full` cleanup mode.
727727
"""
728728
# Behavior is deprecated, but we keep it for backwards compatibility.
729729
# # Warn only once per process.

libs/core/langchain_core/runnables/graph_ascii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def draw_ascii(vertices: Mapping[str, str], edges: Sequence[LangEdge]) -> str:
269269
270270
print(draw_ascii(vertices, edges))
271271
272-
.. code-block:: none
272+
.. code-block::
273273
274274
+---+
275275
| 1 |

0 commit comments

Comments
 (0)