Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: optionally display line numbers in code blocks #799

Draft
wants to merge 1,922 commits into
base: main
Choose a base branch
from

Conversation

snehankekre
Copy link
Contributor

@snehankekre snehankekre commented Aug 30, 2023

📚 Context

The docs can sometimes contain long code blocks. Authors may want to reference specific lines of the code block in preceding or subsequent paragraph text. Doing so without displayed line numbers can be challenging. To that end, this PR introduces a feature to optionally include line numbers in code blocks using the prism line numbers plugin. There are two ways to do:

  1. If using fenced code blocks, include showLineNumbers to the right of ```python. E.g.
```python showLineNumbers
import streamlit as st

st.write("Hello, world!")
```
  1. If using the <Code> component, set the prop showLineNumbers={true}. E.g.
<Code showLineNumbers={true}>
  <code className="language-python">
    {`
    import streamlit as st
    
    st.write("Hello, world!")
    `}
  </code>
</Code>

Since we use code blocks in many places in our docs, and some places where we might not want line numbers (API cards), line numbers are turned off by default.

🧠 Description of Changes

Revised:

image
image

Current:

image
image

💥 Impact

Size:

  • Small
  • Not small

🌐 References

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

snehankekre and others added 30 commits December 8, 2022 16:46
Former-commit-id: dc79473
Explicitly mention that changes to config file while server is live requires restarting the server

Former-commit-id: 1b4cecd
Add line breaks mid-word to API ref param names

Former-commit-id: f02a1f0
Update blog posts on homepage

Former-commit-id: 589f5f5
Add docs for social share previews

Former-commit-id: 8dc357f
Add theming docs for Plotly, Altair,  and Vega-Lite

Former-commit-id: c6446ff
Docs for colored text support

Former-commit-id: 5c54443
Add docs for cached media element+form replay

Former-commit-id: 777f458
* Add 1.16.0 release notes to changelog

* Add the exception layout bug fix PR to changelog

* Include PR numbers only in Other Changes

* Update What's new tiles with latest features

* Update blog posts on homepage

* Bump version to 1.16.0 in cheat sheet and configuration

* Bump version to 1.16.0 in embedded apps

Former-commit-id: f7196eb
Changed 'Thead' to 'Thread' This is my first pull request and I am beyond ecstatic.

Former-commit-id: 363ba7b
github-actions bot and others added 22 commits July 21, 2023 15:10
Co-authored-by: snehankekre <[email protected]>
Former-commit-id: 993872f
Co-authored-by: snehankekre <[email protected]>
Former-commit-id: f5a357c
Corrects typo in the "Customize the menu" section. Attribute to set is `client.toolbarMode`.

Former-commit-id: 7f80f14
Reflect most up-to-date usage.

Former-commit-id: 20c442b
Removed reference to toast as a container for correctness.

Former-commit-id: ee1f506
Add embedded app for LLM Tutorial: OpenAI, LangChain, and Streamlit in 18 lines of code

Former-commit-id: f72d894
* Add tutorial embedded app

Add embedded app for LLM Tutorial: OpenAI, LangChain, and Streamlit in 18 lines of code

* Add LLM tutorial

* Move emoji

Emoji/grammar edit

* Typesetting and style corrections

Former-commit-id: bcaf474
Added a link to LLM quickstart

Former-commit-id: 7ec811e
* Move pagination above helpful component

* Update logic to override prev/next arrows

* Make text larger

* Improve color for border in dark mode

Former-commit-id: fa81bc9
* Dont truncate floating nav

* Add padding to prevent text to overflow

Former-commit-id: 3c9087c
* Community Cloud sign-up and account instructions

Updated Get started page to better describe the accounts used with Streamlit Community Cloud and how to sign up.

* Wording clarity

* Delete duplicate images

This commit duplicate images in public/images/streamlit-cloud that were an artifact of renaming the folder to .../streamlit-community-cloud

* Update sign-in instructions and images

Update sign-in instructions and images for consistency

* Update sign-in-email-3.png

fix: URL mask alignment

* Update Community Cloud Get started

* Update images & move GitHub connection details

More image updates for consistency and better resolution. GitHub connection details moved to a separate page.

* Updated Community Cloud re:default URL

Updated Community Cloud documentation to mention there is a pre-filled custom subdomain and that it can be deleted or changed.

* Updated custom subdomain images

Updated custom subdomain images for consistency and resolution.

* Update app-dependencies.md

Improve explanation of `requirements.txt` and `packages.txt`

* Prettify Python package managers table

Make table of Python package managers prettier.

* Remove Workspace analytics

* Edits for clarity

Small edits for clarity and from feedback

* Move connecting to GitHub

Move Connect to GitHub out of Community Cloud Get started and make a separate page.

* Delete duplicate Connect GitHub

Delete duplicate content from temporary rearrangement.

* Remove duplicate Connect to data sources index

Removed duplicate index of Connect to data sources tutorials.

* Rearrange folder structure in Community Cloud

Move "Deploy your app", "Share your app", and "Manage your app" to the top level of navigation within Community Cloud. Move Trust and Security to Getting started alongs side connecting to GitHub/GitHub authorization.

* Update Get started/Connect GitHub

Updated instructions to connect to GitHub. Included explanation on authorizing organizations.

* Add Community Cloud Quickstart

* Added GItHub account management

Added instructions for connecting and modifying GitHub account permissions after account creation.

* Update links

Update links from file rearrangement

* Update Streamlit Community Cloud index.md

Rearrange tiles on top-level page for Streamlit Community Cloud.

* Split Get started in Community Cloud

Move account creation and workspace exploration to their own sub-pages under Get started.

* Update Community Cloud Quickstart

Change to using the built-in sample app deployment from the New App menu instead of manually forking an example app to deploy.

* Update account creation in Get started

Additional images and edits to document the process of creating a Streamlit Community Cloud account.

* Link updates and clarity edits

Link updates and clarity edits within the pages of Get started in Community Cloud.

* Edit for enterprise language

Revise language in security-model.md

* Update secrets management in Community Cloud

* Update Share your app

Move Manage your app to before Share your app. Update Share your app page including updating and adding images.

* Update Embed your app

* Update indexability.md

* Update share-previews.md

* Create app-analytics.md

Modify description of app analytics and create separate page for it. Update and add images.

* Create favorite-your-app.md

Create separate page for app favoriting. Update and add images.

* Create reboot-your-app.md

Create separate page for rebooting apps. Update and add images.

* Create delete-you-app.md

Create separate page for deleting apps. Update and add images.

* Update index.md for Manage your app

Rearrange content to summarize the different places to access menus. Summarize each menu with links to the associated detail pages. Update and add images.

* Create workspace-settings.md

Create separate page for workspace settings as distinct from app settings. Update and add images.

* Update links, images, and image descriptions

Verify and update links and images from Get started through Manage your app/Workspace settings.

* Update links, images, and image descriptions (Share your app)

Verify and update links and images within Share your app section.

* Remove localhost from link

* Update links, images, and image descriptions (Manage your account section)

Verify and update links and images within Manage your account section.

* Small fixes and typos

* Update main, Community Cloud page

Change summary navigation at the top level of Streamlit Community Cloud.

* Update links to Community Cloud section

* Update header links to Streamlit Community Cloud section

* Update redirects for Community Cloud
Former-commit-id: 0f9b4cc
* Update generate.py

Update generate.py to parse StatusContainer.

* Update st.markdown example app

* Add interactive markdown example

* Add st.toggle embedded app source

* Add embedded app source for chart color parameter

* Switch to nightly for prerelease

* Spacing/formatting in app source

* Embedded app source formatting

* Use type parameter in st.button example

* Typesetting consistency

* Revert st.button example app

Moved change to release branch

* Update title, header, subheader example apps

* Add app source for st.status examples

Former-commit-id: b2877f0
While working on e2e setup for component-template (streamlit/component-template#70) we extract example to separate file, so command for run example component is now invalid.

Former-commit-id: f95d1fd
* Fix scrollbars for mac os

* Remove console log statement

Former-commit-id: 81fbcca
* Add documentation for `st.status` (#783)

* Create st.status page

* Update API cards & docstrings

* Update st.status API card summary

* Add st.status to chat elements in API index

* Add st.toggle documentation (#784)

* Add st.toggle documentation

Add page, API card, and navigation for st.toggle

* Update streamlit.json

---------

Co-authored-by: snehankekre <[email protected]>

* Feature/enable deploy button (#787)

* Add deployment button gif

* Move deploy button in app menu docs

* Update image borders in app-menu.md

* Sync streamlit.json with release branch

---------

Co-authored-by: snehankekre <[email protected]>

* Release 1.26 (#785)

* Add captions and markdown to st.radio example

* Update streamlit.json

* Remove static images for title, header, subheader

* Update markdown.md

Add interactive embedded app

* Update changelog for 1.26.0

* Update embedded apps to 1.26.0

* Use relative internal links in changelog for performance reasons

* Fix Markdown issue in download button point

* Move incorrect PR about number input into notable changes

* Don't reference PR 7154 in other changes

* Change impact label and add PR 7143 to other changes

* Update cheatsheet and configuration.md

* Update What's new

---------

Co-authored-by: snehankekre <[email protected]>

* Update streamlit.json (#790)

* Update streamlit.json

* Update widget.button.py

---------

Co-authored-by: snehankekre <[email protected]>
Former-commit-id: 2abd435
Co-authored-by: snehankekre <[email protected]>
Former-commit-id: ad5319a
@snehankekre snehankekre changed the title Feature/numbered Feature: optionally display line numbers in code blocks Aug 30, 2023
@snehankekre snehankekre marked this pull request as draft August 30, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.