APIDoc 4.0 includes 160+ professional syntax highlighting themes powered by highlight.js, providing beautiful code formatting for all supported programming languages.
{
"name": "My API",
"version": "1.0.0",
"template": {
"highlightTheme": "github-dark"
}
}
{
"template": {
"highlightTheme": "atom-one-dark",
"highlightLanguages": [
"typescript",
"javascript",
"python",
"java",
"go",
"rust",
"php",
"bash",
"json",
"yaml",
"dockerfile",
"nginx"
]
}
}
{
"template": {
"highlightTheme": "github-dark"
}
}
Features:
{
"template": {
"highlightTheme": "atom-one-light"
}
}
Features:
{
"template": {
"highlightTheme": "monokai"
}
}
Features:
/* custom-highlight.css */
.hljs {
background: #2d3748;
color: #e2e8f0;
padding: 1rem;
border-radius: 8px;
font-family: 'Fira Code', 'Consolas', monospace;
}
/* Keywords */
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
color: #4fd1c7;
font-weight: 600;
}
/* Strings */
.hljs-string,
.hljs-attr {
color: #9ae6b4;
}
/* Numbers */
.hljs-number,
.hljs-literal {
color: #feb2b2;
}
/* Comments */
.hljs-comment,
.hljs-quote {
color: #718096;
font-style: italic;
}
/* Functions */
.hljs-function,
.hljs-title {
color: #90cdf4;
font-weight: 600;
}
/* Variables */
.hljs-variable,
.hljs-name {
color: #fbb6ce;
}
/* Operators */
.hljs-operator {
color: #f6e05e;
}
{
"template": {
"customCSS": "./assets/custom-highlight.css",
"highlightTheme": "none"
}
}
/**
* @api {post} /users Create User
* @apiName CreateUser
* @apiGroup Users
*/
async function createUser(userData: UserData): Promise<User> {
const user = await User.create({
name: userData.name,
email: userData.email,
role: userData.role || 'user'
});
return user;
}
"""
@api {get} /analytics/report Generate Report
@apiName GenerateReport
@apiGroup Analytics
"""
def generate_report(start_date: datetime, end_date: datetime) -> Dict[str, Any]:
data = fetch_analytics_data(start_date, end_date)
report = {
'period': f"{start_date} to {end_date}",
'total_users': len(data['users']),
'revenue': sum(data['transactions'])
}
return report
/**
* @api {put} /products/{id} Update Product
* @apiName UpdateProduct
* @apiGroup Products
*/
func UpdateProduct(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
productID := vars["id"]
var product Product
if err := json.NewDecoder(r.Body).Decode(&product); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
updatedProduct, err := productService.Update(productID, product)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(updatedProduct)
}
/**
* @api {delete} /cache/{key} Delete Cache Key
* @apiName DeleteCacheKey
* @apiGroup Cache
*/
pub async fn delete_cache_key(
Path(key): Path<String>,
State(cache): State<Arc<Cache>>,
) -> Result<StatusCode, AppError> {
match cache.delete(&key).await {
Ok(_) => Ok(StatusCode::NO_CONTENT),
Err(e) => {
tracing::error!("Failed to delete cache key {}: {}", key, e);
Err(AppError::CacheError(e))
}
}
}
{
"template": {
"highlightLanguages": [
"typescript", "javascript", "python", "java", "go", "rust",
"php", "ruby", "swift", "kotlin", "dart", "scala",
"bash", "powershell", "dockerfile", "yaml", "json",
"sql", "graphql", "nginx", "apache"
]
}
}
{
"template": {
"highlightTheme": "github",
"highlightOnDemand": true,
"highlightMinified": true,
"highlightLanguages": ["javascript", "typescript", "json"]
}
}
// Register custom language
hljs.registerLanguage('apidoc', function(hljs) {
return {
contains: [
{
className: 'meta',
begin: '@api',
end: '$'
},
{
className: 'string',
begin: '{',
end: '}'
}
]
};
});
@media (max-width: 768px) {
.hljs {
font-size: 14px;
padding: 0.75rem;
overflow-x: auto;
}
.hljs-line {
white-space: nowrap;
}
}
// Auto-switch theme based on system preference
function setThemeBasedOnSystem() {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = prefersDark ? 'github-dark' : 'github';
document.querySelector('link[href*="highlight"]').href =
`./css/highlight-${theme}.css`;
}
// Listen for system theme changes
window.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', setThemeBasedOnSystem);
With 160+ themes available, APIDoc provides the flexibility to match any design aesthetic while maintaining excellent code readability and professional appearance.