Source text — English
Translation — Bahasa Indonesia
:mod:`!pydoc` --- Documentation generator and online help system
:mod:`!pydoc` --- Generator dokumentasi dan sistem bantuan daring
**Source code:** :source:`Lib/pydoc.py`
**Kode sumber:** :source:`Lib/pydoc.py`
The :mod:`!pydoc` module automatically generates documentation from Python modules. The documentation can be presented as pages of text on the console, served to a web browser, or saved to HTML files.
Modul :mod:`!pydoc` secara otomatis menghasilkan dokumentasi dari modul-modul Python. Dokumentasi dapat disajikan sebagai halaman-halaman teks pada konsol, disajikan ke peramban web, atau disimpan ke berkas-berkas HTML.
For modules, classes, functions and methods, the displayed documentation is derived from the docstring (i.e. the :attr:`~definition.__doc__` attribute) of the object, and recursively of its documentable members. If there is no docstring, :mod:`!pydoc` tries to obtain a description from the block of comment lines just above the definition of the class, function or method in the source file, or at the top of the module (see :func:`inspect.getcomments`).
Untuk modul, kelas, fungsi, dan metode, dokumentasi yang ditampilkan diturunkan dari docstring (yaitu atribut :attr:`~definition.__doc__` dari objek), dan secara rekursif dari anggota-anggotanya yang dapat didokumentasikan. Jika tidak ada docstring, :mod:`!pydoc` mencoba memperoleh deskripsi dari blok baris komentar tepat di atas definisi kelas, fungsi, atau metode dalam berkas sumber, atau di bagian atas modul (lihat :func:`inspect.getcomments`).💬 1
The built-in function :func:`help` invokes the online help system in the interactive interpreter, which uses :mod:`!pydoc` to generate its documentation as text on the console. The same text documentation can also be viewed from outside the Python interpreter by running :program:`pydoc` as a script at the operating system's command prompt. For example, running ::
Fungsi bawaan :func:`help` memanggil sistem bantuan daring dalam interpreter interaktif, yang menggunakan :mod:`!pydoc` untuk menghasilkan dokumentasinya sebagai teks pada konsol. Dokumentasi teks yang sama juga dapat dilihat dari luar interpreter Python dengan menjalankan :program:`pydoc` sebagai skrip pada prompt perintah sistem operasi. Misalnya, menjalankan ::
python -m pydoc sys
python -m pydoc sys
at a shell prompt will display documentation on the :mod:`sys` module, in a style similar to the manual pages shown by the Unix :program:`man` command. The argument to :program:`pydoc` can be the name of a function, module, or package, or a dotted reference to a class, method, or function within a module or module in a package. If the argument to :program:`pydoc` looks like a path (that is, it contains the path separator for your operating system, such as a slash in Unix), and refers to an existing Python source file, then documentation is produced for that file.
pada prompt shell akan menampilkan dokumentasi tentang modul :mod:`sys`, dalam gaya yang mirip dengan halaman manual yang ditampilkan oleh perintah Unix :program:`man`. Argumen untuk :program:`pydoc` dapat berupa nama sebuah fungsi, modul, atau paket, atau referensi bertitik ke sebuah kelas, metode, atau fungsi dalam sebuah modul atau modul dalam sebuah paket. Jika argumen untuk :program:`pydoc` tampak seperti sebuah path (yaitu, mengandung pemisah path untuk sistem operasi Anda, seperti garis miring pada Unix), dan merujuk ke sebuah berkas sumber Python yang ada, maka dokumentasi dihasilkan untuk berkas tersebut.💬 1
In order to find objects and their documentation, :mod:`!pydoc` imports the module(s) to be documented. Therefore, any code on module level will be executed on that occasion. Use an ``if __name__ == '__main__':`` guard to only execute code when a file is invoked as a script and not just imported.
Untuk menemukan objek beserta dokumentasinya, :mod:`!pydoc` mengimpor modul yang akan didokumentasikan. Oleh karena itu, kode apa pun pada tingkat modul akan dieksekusi pada kesempatan tersebut. Gunakan pelindung ``if __name__ == '__main__':`` untuk mengeksekusi kode hanya ketika sebuah berkas dipanggil sebagai skrip dan bukan sekadar diimpor.
When printing output to the console, :program:`pydoc` attempts to paginate the output for easier reading. If either the :envvar:`MANPAGER` or the :envvar:`PAGER` environment variable is set, :program:`pydoc` will use its value as a pagination program. When both are set, :envvar:`MANPAGER` is used.
Ketika mencetak keluaran ke konsol, :program:`pydoc` mencoba melakukan paginasi pada keluaran agar lebih mudah dibaca. Jika variabel lingkungan :envvar:`MANPAGER` atau :envvar:`PAGER` diatur, :program:`pydoc` akan menggunakan nilainya sebagai program paginasi. Ketika keduanya diatur, :envvar:`MANPAGER` yang digunakan.
Specifying a ``-w`` flag before the argument will cause HTML documentation to be written out to a file in the current directory, instead of displaying text on the console.
Menentukan flag ``-w`` sebelum argumen akan menyebabkan dokumentasi HTML ditulis ke sebuah berkas dalam direktori saat ini, alih-alih menampilkan teks pada konsol.
Specifying a ``-k`` flag before the argument will search the synopsis lines of all available modules for the keyword given as the argument, again in a manner similar to the Unix :program:`man` command. The synopsis line of a module is the first line of its documentation string.
Menentukan flag ``-k`` sebelum argumen akan mencari baris sinopsis dari semua modul yang tersedia untuk kata kunci yang diberikan sebagai argumen, sekali lagi dengan cara yang mirip dengan perintah Unix :program:`man`. Baris sinopsis sebuah modul adalah baris pertama dari string dokumentasinya.
You can also use :program:`pydoc` to start an HTTP server on the local machine that will serve documentation to visiting web browsers. :program:`python -m pydoc -p 1234` will start a HTTP server on port 1234, allowing you to browse the documentation at ``http://localhost:1234/`` in your preferred web browser. Specifying ``0`` as the port number will select an arbitrary unused port.
Anda juga dapat menggunakan :program:`pydoc` untuk memulai server HTTP pada mesin lokal yang akan menyajikan dokumentasi ke peramban web yang berkunjung. :program:`python -m pydoc -p 1234` akan memulai server HTTP pada port 1234, yang memungkinkan Anda menjelajahi dokumentasi di ``http://localhost:1234/`` pada peramban web pilihan Anda. Menentukan ``0`` sebagai nomor port akan memilih sebuah port yang tidak digunakan secara sembarang.
The :mod:`!pydoc` HTTP server is intended for local use during development and is not suitable for production use.
Server HTTP :mod:`!pydoc` dimaksudkan untuk penggunaan lokal selama pengembangan dan tidak cocok untuk digunakan di lingkungan produksi.
:program:`python -m pydoc -n <hostname>` will start the server listening at the given hostname. By default the hostname is 'localhost' but if you want the server to be reached from other machines, you may want to change the host name that the server responds to. During development this is especially useful if you want to run pydoc from within a container.
:program:`python -m pydoc -n <hostname>` akan memulai server yang mendengarkan pada hostname yang diberikan. Secara default hostname adalah 'localhost', tetapi jika Anda ingin server dapat dijangkau dari mesin lain, Anda mungkin ingin mengubah nama host yang direspons oleh server. Selama pengembangan, hal ini sangat berguna jika Anda ingin menjalankan pydoc dari dalam sebuah container.💬 2
:program:`python -m pydoc -b` will start the server and additionally open a web browser to a module index page. Each served page has a navigation bar at the top where you can *Get* help on an individual item, *Search* all modules with a keyword in their synopsis line, and go to the *Module index*, *Topics* and *Keywords* pages.
:program:`python -m pydoc -b` akan memulai server dan juga membuka peramban web ke halaman indeks modul. Setiap halaman yang disajikan memiliki bilah navigasi di bagian atas tempat Anda dapat *Get* bantuan tentang sebuah item individual, *Search* semua modul dengan kata kunci dalam baris sinopsisnya, dan menuju ke halaman *Module index*, *Topics*, dan *Keywords*.
When :program:`pydoc` generates documentation, it uses the current environment and path to locate modules. Thus, invoking :program:`pydoc spam` documents precisely the version of the module you would get if you started the Python interpreter and typed ``import spam``.
Ketika :program:`pydoc` menghasilkan dokumentasi, ia menggunakan environment dan path saat ini untuk menemukan modul. Dengan demikian, memanggil :program:`pydoc spam` mendokumentasikan secara tepat versi modul yang akan Anda dapatkan jika Anda memulai interpreter Python dan mengetik ``import spam``.
Module docs for core modules are assumed to reside in ``https://docs.python.org/X.Y/library/`` where ``X`` and ``Y`` are the major and minor version numbers of the Python interpreter. This can be overridden by setting the :envvar:`!PYTHONDOCS` environment variable to a different URL or to a local directory containing the Library Reference Manual pages.
Dokumen modul untuk modul-modul inti diasumsikan berada di ``https://docs.python.org/X.Y/library/`` dengan ``X`` dan ``Y`` adalah nomor versi mayor dan minor dari interpreter Python. Hal ini dapat diubah dengan mengatur variabel lingkungan :envvar:`!PYTHONDOCS` ke URL yang berbeda atau ke direktori lokal yang berisi halaman-halaman Manual Referensi Pustaka.
Added the ``-b`` option.
Menambahkan opsi ``-b``.
The ``-g`` command line option was removed.
Opsi baris perintah ``-g`` telah dihapus.
:mod:`!pydoc` now uses :func:`inspect.signature` rather than :func:`inspect.getfullargspec` to extract signature information from callables.
:mod:`!pydoc` kini menggunakan :func:`inspect.signature` alih-alih :func:`inspect.getfullargspec` untuk mengekstrak informasi signatur dari callable.
Added the ``-n`` option.
Menambahkan opsi ``-n``.
documentation
dokumentasi
generation
pembuatan
online
daring
help
bantuan
Select an entry in the list to start translating.