Skip to content

Commit

Permalink
Finish translating into Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Jan 8, 2025
1 parent 1852c96 commit 1dbdf10
Show file tree
Hide file tree
Showing 32 changed files with 3,226 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/sphinx_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- name: Add execute permission to build.sh
run: |
chmod +x docs/tutorial/en/build.sh
- id: build
name: Build Documentation
- id: build_en
name: Build English Documentation
env:
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
run: |
Expand All @@ -47,5 +47,5 @@ jobs:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: 'docs/tutorial/build/html'
publish_dir: 'docs/tutorial/en/build/html'
cname: doc.agentscope.io
2 changes: 1 addition & 1 deletion docs/tutorial/en/source/tutorial/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ def reply(self, msg):
#
# Further Reading
# ---------------------
# - :ref:`builtin-agent`
# - :ref:`builtin_agent`
# - :ref:`model_api`
4 changes: 2 additions & 2 deletions docs/tutorial/en/source/tutorial/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import json

print(json.dumps(agentscope.state_dict(), indent=2))
print(json.dumps(agentscope.state_dict(), indent=2, ensure_ascii=False))

# %%
# Monitoring the Runtime
Expand Down Expand Up @@ -70,4 +70,4 @@

usage = agentscope.print_llm_usage()

print(json.dumps(usage, indent=2))
print(json.dumps(usage, indent=2, ensure_ascii=False))
20 changes: 20 additions & 0 deletions docs/tutorial/zh/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
9 changes: 9 additions & 0 deletions docs/tutorial/zh/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

# Generate the API rst files
sphinx-apidoc -o source/build_api ../../../src/agentscope -t source/_templates -e

# Build the html
sphinx-build -M html source build
35 changes: 35 additions & 0 deletions docs/tutorial/zh/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
83 changes: 83 additions & 0 deletions docs/tutorial/zh/source/_static/css/gallery.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.sphx-glr-download-link-note.admonition.note {
display: none;
}

.sphx-glr-download {
display: none;
}

.bordered-image {
border: 1px solid gray;
}

:root {
--item-card-width: 200px;
--item-card-margin: 10px;
--item-card-title-height: 50px;

--item-card-img-length: calc(var(--item-card-width) - 2*var(--item-card-margin));
--item-card-title-width: calc(var(--item-card-width) - 2*var(--item-card-margin));
--item-card-title-margin-top: var(--item-card-margin);

--item-card-height: calc(var(--item-card-margin) * 3 + var(--item-card-img-length) + var(--item-card-title-height));
}

.gallery-item {
position: relative;
display: inline-block;
width: var(--item-card-width);
height: var(--item-card-height);
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
margin: 7px;
}

.gallery-item-card {
position: absolute;
top: 0;
left: 0;
width: var(--item-card-width);
height: var(--item-card-height);
display: flex;
flex-direction: column;
margin: var(--item-card-margin);
}

.gallery-item-card-img {
height: var(--item-card-img-length);
width: var(--item-card-img-length);
min-width: var(--item-card-img-length);
min-height: var(--item-card-img-length);
display: block;
}

.gallery-item-card-title {
text-align: center;
margin-top: var(--item-card-margin);
font-weight: bold;
min-height: var(--item-card-title-height);
height: var(--item-card-title-height);
width: var(--item-card-title-width);
display: flex;
align-items: center;
justify-content: center;
}

.gallery-item-description {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.9);
/*background-color: #1e8449;*/
color: black;
display: none;
justify-content: center;
align-items: flex-start;
}

.gallery-item:hover .gallery-item-description {
display: flex;
padding: 10px;
border: 1px solid rgba(0, 0, 0, 0.22);
}
5 changes: 5 additions & 0 deletions docs/tutorial/zh/source/_templates/module.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ basename | heading }}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}
10 changes: 10 additions & 0 deletions docs/tutorial/zh/source/_templates/package.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{%- macro automodule(modname, options) -%}
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
{%- endfor %}
{%- endmacro %}

{{- pkgname | heading }}

{{ automodule(pkgname, automodule_options) }}
79 changes: 79 additions & 0 deletions docs/tutorial/zh/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "AgentScope Doc"
copyright = "2025, Alibaba"
author = "Alibaba Tongyi Lab"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"myst_parser",
"sphinx_gallery.gen_gallery",
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
]

myst_enable_extensions = [
"colon_fence",
]

sphinx_gallery_conf = {
"download_all_examples": False,
"examples_dirs": [
"tutorial",
],
"gallery_dirs": [
"build_tutorial",
],
"filename_pattern": "tutorial/.*\.py",
"example_extensions": [".py"],
}

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

languages = ["en", "zh_CN"]
language = "en"

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

html_css_files = [
"css/gallery.css",
]

source_suffix = [".md", ".rst"]


# -- Options for API documentation -------------------------------------------

autodoc_member_order = "groupwise"
add_module_names = False
python_display_short_literal_types = True


def skip_member(app, what, name, obj, skip, options):
if name in [
"Operator",
"ServiceFactory",
"",
]:
return True

return skip


def setup(app):
app.connect("autodoc-skip-member", skip_member)
64 changes: 64 additions & 0 deletions docs/tutorial/zh/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. AgentScope Doc documentation master file, created by
sphinx-quickstart on Thu Aug 8 15:07:21 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to AgentScope's documentation!
==========================================

.. toctree::
:maxdepth: 1
:caption: Tutorial

build_tutorial/quickstart
build_tutorial/message
build_tutorial/agent
build_tutorial/conversation

.. toctree::
:maxdepth: 1
:caption: FQA

tutorial/faq

.. toctree::
:maxdepth: 1
:caption: Task Guides

build_tutorial/model
build_tutorial/prompt
build_tutorial/structured_output
build_tutorial/streaming
build_tutorial/builtin_agent
build_tutorial/multimodality
build_tutorial/visual
build_tutorial/monitor
build_tutorial/tool
tutorial/rag
build_tutorial/distribution
build_tutorial/prompt_optimization
build_tutorial/web_browser
build_tutorial/low_code


.. toctree::
:maxdepth: 1
:caption: Examples

build_tutorial/examples

.. toctree::
:maxdepth: 1
:caption: API Docs

build_api/agentscope
build_api/agentscope.message
build_api/agentscope.models
build_api/agentscope.agents
build_api/agentscope.memory
build_api/agentscope.parsers
build_api/agentscope.rag
build_api/agentscope.service
build_api/agentscope.prompt
build_api/agentscope.tokens
build_api/agentscope.exception
Empty file.
Loading

0 comments on commit 1dbdf10

Please sign in to comment.