-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Enhancements to ScalaDoc: New Features Implemented #21436
Draft
sai-prasad-1
wants to merge
25
commits into
scala:main
Choose a base branch
from
sai-prasad-1:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8fc1f15
Added AltDetails Block
sai-prasad-1 feac040
Update : liqp version to 0.9
sai-prasad-1 89d11f9
Added Tabs Block
sai-prasad-1 b2eab74
Added Include Tag
sai-prasad-1 5351239
Update Nameing
sai-prasad-1 5fa510a
Added Include Tag and optimise alt-details
sai-prasad-1 44e670e
Update styling for alt-details and tabs
sai-prasad-1 907584b
Fix Front-matter parser
sai-prasad-1 f25ab16
Update Tabs Block to use Radio Buttons
sai-prasad-1 c5b5450
Update : Added Langauge Picker
sai-prasad-1 76247e9
Fix Config Path
sai-prasad-1 44548bb
Update Config Loader
sai-prasad-1 b8b94ab
Update Langauge Picker
sai-prasad-1 8ddd55f
Update : check for langauge folder existance
sai-prasad-1 942b643
Fix : DataLoader to use java data structures
sai-prasad-1 ecf9265
feat: Handle empty `languages` argument in LanguagePickerTag gracefully
sai-prasad-1 7ce1ed2
Added Config Values to
sai-prasad-1 2d1818f
Fix : Langauge Picker - Interative Redirect
sai-prasad-1 9b15ebd
feat(config): add method to convert configuration data to Java Map
sai-prasad-1 1fd197d
Clean up Print Statements
sai-prasad-1 798b9ac
Remove Unwanted Files
sai-prasad-1 6222ab2
Remove Empty Files
sai-prasad-1 bb9b8c0
move scaladoc documentation `internals` section
sai-prasad-1 f9c1c1f
Update scaladoc/src/dotty/tools/scaladoc/site/blocks/Tabs.scala
sai-prasad-1 0cab089
Enable experimental features conditionally based on flag
sai-prasad-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
--- | ||
layout: doc-page | ||
title: Scaladoc | ||
partof: scaladoc | ||
overview-name: Scaladoc | ||
num: 1 | ||
|
||
--- | ||
|
||
|
||
# Custom Template Tags Documentation | ||
|
||
|
||
## 1. Language Picker Tag | ||
|
||
The language_picker tag is a custom tag used to render a language selection dropdown on a page. This tag allows users to switch between different language versions of the content. The available languages are determined based on the configuration and the frontmatter of the page. | ||
|
||
### Prequisites: | ||
- #### Configuration in config.yaml: | ||
The available languages must be defined in the `config.yaml` file under the languages section. Each language should have a corresponding code and name. | ||
Example: | ||
```yaml | ||
languages: | ||
- code: en | ||
name: English | ||
- code: ja | ||
name: Japanese | ||
``` | ||
- #### Language Folders in `_docs`: | ||
For each language code specified in config.yaml, there should be a corresponding folder in the _docs directory. These folders contain the translated content for each language. | ||
Example: | ||
``` | ||
_docs/ | ||
├── en/ | ||
├── ja/ | ||
|
||
``` | ||
- #### Frontmatter in the page: | ||
Each page should have a `languages` key in its frontmatter that lists the available languages for that page. This ensures that the language picker dropdown is rendered with the correct options. | ||
|
||
Example: | ||
```yaml | ||
--- | ||
title: Getting Started | ||
languages: ['en', 'ja'] | ||
--- | ||
``` | ||
|
||
### Usage: | ||
|
||
```html | ||
<div class="language-picker-container"> | ||
{ % if page.languages % } | ||
{ % language_picker languages=page.languages % } | ||
{ % endif %} | ||
</div> | ||
``` | ||
|
||
### Considerations | ||
|
||
- Empty Language List: If the languages list in the frontmatter is empty, the language_picker tag will not render anything. | ||
- Default Language: If the selected language is en, the language code will be removed from the URL, treating it as the default language. | ||
- Folder Structure: Ensure that the corresponding language folders exist in the _docs directory; otherwise, the language switch will lead to broken links. | ||
|
||
|
||
|
||
## 1. Include Tag | ||
|
||
### Purpose: | ||
The `{ % include % }` tag is used to include content from other files or templates within your page. This helps in reusing common elements across multiple pages, such as headers, footers, or any other repeated content. | ||
|
||
### Usage: | ||
```html | ||
{ % include 'filename' variable1='value1' variable2='value2' % } | ||
``` | ||
|
||
|
||
### Example: | ||
```html | ||
{ % include 'header.html' title='Welcome to My Website' % } | ||
``` | ||
|
||
### How it Works: | ||
- File Inclusion: The tag includes the specified file from a predefined folder. | ||
- Passing Variables: You can pass variables when including a file, which can be accessed within the included file using the syntax {{ include.variable1 }}. | ||
- Accessing Variables: Inside the included file, the passed variables can be accessed like regular variables, allowing dynamic content based on the context of inclusion. | ||
|
||
|
||
|
||
## 2. Tabs Block | ||
|
||
### Purpose: | ||
The { % tabs % } block is used to group content into tabs, allowing users to switch between different content sections without reloading the page. This is useful for organizing content that has multiple views, like installation instructions for different platforms. | ||
|
||
### Usage: | ||
```html | ||
{ % tabs unique-tabs-id class='additional-class' % } | ||
{ % tab 'Tab 1' for='unique-tabs-id' % } | ||
<!-- Content for Tab 1 --> | ||
{ % endtab % } | ||
|
||
{ % tab 'Tab 2' for='unique-tabs-id' % } | ||
<!-- Content for Tab 2 --> | ||
{ % endtab % } | ||
|
||
{ % endtabs % } | ||
``` | ||
|
||
### Example: | ||
|
||
```html | ||
{ % tabs install-instructions % } | ||
{ % tab 'Windows' for='install-instructions' % } | ||
|
||
{ % endtab % } | ||
|
||
{ % tab 'macOS' for='install-instructions' % } | ||
|
||
{ % endtab % } | ||
|
||
{ % endtabs % } | ||
``` | ||
|
||
How it Works: | ||
- Tabs Block: The { % tabs % } tag creates a container for multiple tabs. | ||
- Tab Content: Each { % tab % } tag defines the content of a single tab. The for attribute must match the id specified in the { % tabs % } block to correctly link the tab content. | ||
- Default Tab: You can specify a default tab by using the defaultTab keyword in the { % tab % } tag. | ||
- Styling: You can apply additional CSS classes to the tabs by specifying the class attribute | ||
|
||
|
||
## 2. AltDetails Block | ||
|
||
### Purpose: | ||
The { % altDetails % } tag is used to create switchable sections, often referred to as tabs. This is useful for including optional or advanced information that doesn’t need to be visible by default. | ||
|
||
### Usage: | ||
|
||
```html | ||
{ % altDetails 'unique-id' 'Title of the Section' % } | ||
<!-- Content inside the dropdown --> | ||
{ % endaltDetails %} | ||
|
||
``` | ||
|
||
### How it Works: | ||
|
||
- Collapsible Section: The { % altDetails % } tag creates a section that can be expanded or collapsed by the user. | ||
- Title and ID: The first argument is a unique identifier for the section, and the second argument is the title displayed when the section is collapsed. | ||
- Content: Any content placed within the { % altDetails % } and { % endaltDetails % } tags is hidden by default and can be revealed by clicking on the title. | ||
|
||
|
||
# `_data` Folder | ||
|
||
The _data folder in your project is used to store YAML, JSON, or CSV files that contain structured data. These files can then be accessed throughout your site using the site.data variable. This is particularly useful for storing site-wide information, such as navigation menus, reusable content blocks, or any other structured data that needs to be referenced across multiple pages. | ||
|
||
### Structure and Access | ||
- Folder Location: The _data folder should be located in the root directory of your project. | ||
|
||
- File Formats: The _data folder supports .yml, .yaml, .json, and .csv file formats. Each file represents a collection of data that can be accessed using the site.data variable. | ||
|
||
- Accessing Data: | ||
- The data within a YAML file can be accessed using `site.data.<file_name>.<key>.` | ||
- Replace `<file_name>` with the name of the file (without the extension), and `<key>` with the specific key within the file. | ||
|
||
### Example | ||
|
||
Suppose you have a YAML file `_data/navigation.yml` with the following content: | ||
|
||
```yaml | ||
main_menu: | ||
- name: Home | ||
url: / | ||
- name: About | ||
url: /about/ | ||
- name: Contact | ||
url: /contact/ | ||
``` | ||
|
||
You can access the data in this file using the following syntax: | ||
|
||
```html | ||
<ul> | ||
{ % for item in site.data.navigation.main_menu % } | ||
<li><a href="{ { item.url } }">{ { item.name } }</a></li> | ||
{ % endfor % } | ||
</ul> | ||
``` | ||
|
||
### Considerations | ||
- File Naming: Make sure the file names are unique to avoid conflicts when accessing data. | ||
- Data Structure: Keep the data structure consistent across different files to avoid confusion when accessing data in your templates. | ||
|
||
<aside class="info"> | ||
<div class='icon'></div> | ||
<div class='content'> | ||
It is preferred to avoid using hyphens in naming conventions. When using LIQP tags, hyphens can be misinterpreted as minus signs, leading to unexpected errors. | ||
<br/> | ||
{ { site.data.example['key-with-hyphen'] } } | ||
|
||
</div> | ||
</aside> | ||
|
||
|
||
|
||
|
||
|
||
# Configuration File | ||
|
||
The `_config.yaml` file is a central configuration file located in the root directory of your project. It is used to define site-wide settings and variables that can be accessed throughout your site using the `site` variable. | ||
|
||
### Structure and Access | ||
|
||
- File Location: The _config.yaml file should be placed in the root directory of your project. | ||
|
||
- YAML Structure: The file uses YAML syntax to define configuration options. You can define any key-value pairs in this file, and they will be accessible via the site.config.`<key>` variable in your templates. | ||
|
||
- Accessing Configuration: | ||
- Any configuration setting defined in _config.yaml can be accessed using site.`<key>`. | ||
- For example, if you define a key title: My Website, you can access it using site.title. | ||
|
||
### Example | ||
If your _config.yaml includes: | ||
```yaml | ||
site_name: My Awesome Site | ||
description: A description of my awesome site. | ||
``` | ||
You can access these values in your templates: | ||
```html | ||
{ { site.config.site_name } } <!-- Outputs: My Awesome Site --> | ||
``` | ||
|
||
|
||
|
||
<aside class="info"> | ||
<div class='icon'></div> | ||
<div class='content'> | ||
It is preferred to avoid using hyphens in naming conventions. When using LIQP tags, hyphens can be misinterpreted as minus signs, leading to unexpected errors. | ||
<br/> | ||
{ { site.data.example['key-with-hyphen'] } } | ||
</div> | ||
</aside> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
scaladoc/resources/dotty_res/scripts/staticsite/alt-details.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Get all the alt-details-control elements | ||
const altDetailsControls = document.querySelectorAll('.alt-details-control'); | ||
|
||
// Loop through each control element | ||
altDetailsControls.forEach(control => { | ||
// Add event listener for 'change' event | ||
control.addEventListener('change', function() { | ||
// Get the corresponding alt-details-detail element | ||
const detailElement = this.nextElementSibling.nextElementSibling; | ||
|
||
// Toggle the display of the detail element based on checkbox state | ||
if (this.checked) { | ||
detailElement.style.display = 'block'; | ||
} else { | ||
detailElement.style.display = 'none'; | ||
} | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for context, this was necessary to support the custom syntax